Compare commits
579 Commits
382bc35dfc
...
renovate/t
Author | SHA1 | Date | |
---|---|---|---|
b8c97f9e6a | |||
60fd656b94 | |||
9f25e39cca | |||
0c178daf55 | |||
8dbc5c452e | |||
e5ee0b4d77 | |||
bc3bfe08c6 | |||
f2d391a430 | |||
764a7d94e3 | |||
aea6a64896 | |||
9c728f312b | |||
c7d4056dc3 | |||
555e72ef22 | |||
f35926dfb6 | |||
067ac5181b | |||
b83314f540 | |||
3203d12aac | |||
fae4e144f4 | |||
8179c7a6d6 | |||
a42b887a74 | |||
84ed2c6754 | |||
126920b41f | |||
24fa207005 | |||
40901c55db | |||
fd870317dd | |||
4f6d4abb43 | |||
94da037d55 | |||
88e8c9bf05 | |||
40bbfd9adf | |||
c803ccb212 | |||
db98ff4ed2 | |||
44c54112b6 | |||
cdcb86913f | |||
fcfe457514 | |||
55745f5845 | |||
2ee8bc337f | |||
e441480bf7 | |||
c84817d190 | |||
f615291950 | |||
b95aa90836 | |||
22d2bbfc41 | |||
069ca185cc | |||
9b8f2bd3cf | |||
6c9a0db8d5 | |||
877b0c56b3 | |||
25cae9b006 | |||
fdd11e7eae | |||
9bb93b72cc | |||
f82a788bb0 | |||
2e52958e64 | |||
18cf96d22c | |||
fc63a2935f | |||
c48807bf4b | |||
c896b2cc51 | |||
5a0e720952 | |||
8e2cd9824d | |||
aabec5f0b8 | |||
a763568f6e | |||
8cbf1c5d5d | |||
79c3d669e4 | |||
b68c6f9ee5 | |||
7bf50a8971 | |||
769baa49f1 | |||
1a706ee6a3 | |||
0e79202c77 | |||
4f75833414 | |||
ca6b5d398b | |||
c6e53d5790 | |||
646bf2c0aa | |||
ff95904360 | |||
46eb2c9534 | |||
74efe64282 | |||
2fbbe5a7b4 | |||
7429105374 | |||
dc9bde7ca0 | |||
8b567f9b22 | |||
fa50282a62 | |||
917ba8aa06 | |||
9541caf60d | |||
47c0110944 | |||
e029ae8750 | |||
697ce13a40 | |||
5c8e1b317f | |||
c85b07dde3 | |||
92491f8c4e | |||
ff7042d33a | |||
540ec4e9d9 | |||
6262fab066 | |||
8527ea9336 | |||
0f840d514e | |||
e72a69e696 | |||
e7a84280e7 | |||
6091a73575 | |||
098841359f | |||
f5532cc595 | |||
9e89784002 | |||
0e9a9fd3de | |||
349387bf87 | |||
0d2daccc67 | |||
647c04f78f | |||
459de40e8c | |||
3d62c7b0f7 | |||
6fc8a4589d | |||
b95e2b2a29 | |||
6344465926 | |||
61f927ef2a | |||
0a6b3466de | |||
7683ca208d | |||
8cd47f4337 | |||
ba5d0b6947 | |||
dca62e6c26 | |||
a58ad707ee | |||
a25da9a931 | |||
4ea1197238 | |||
78614b07c2 | |||
07d95d8b63 | |||
349793218b | |||
c31659cb66 | |||
9ceb291bb9 | |||
87d15a8cfb | |||
7dce4b7ec0 | |||
3994687193 | |||
e695357df0 | |||
5bcc3343a3 | |||
441f41b896 | |||
e8b64251b4 | |||
fc885be7e0 | |||
3870600372 | |||
6218503478 | |||
0162bcf256 | |||
3e44dbc308 | |||
45e104bacb | |||
2ffc8c6688 | |||
c86f004dea | |||
e36c57db63 | |||
19fdf3a5ab | |||
d4b16d1998 | |||
33253221eb | |||
12f9c83afc | |||
90a2f09ee6 | |||
7355215108 | |||
ed6d8176b7 | |||
197280e25f | |||
13bcc70440 | |||
a187a3d1ac | |||
5967041ca6 | |||
c57d80411c | |||
8e55b32537 | |||
fd90d83274 | |||
b208117e96 | |||
ccd7c163e3 | |||
a53aabf0e7 | |||
e77b4d0cbe | |||
8fc2657ef6 | |||
7a49d68ce3 | |||
27a82c6f05 | |||
0601eff4c2 | |||
9e01b8886e | |||
d43a545b21 | |||
48ef4a14d4 | |||
25c3f775a5 | |||
91b726c679 | |||
4667cbcce3 | |||
33d8d46e5a | |||
b21c5f280c | |||
55a1715f16 | |||
9e652e9f84 | |||
a66d8eca8a | |||
37f36b1f0b | |||
adf5d9454b | |||
730ceb6306 | |||
89091c1159 | |||
a83cb39c74 | |||
fa49a848f5 | |||
41f41af250 | |||
7aab4a0958 | |||
942dd9bcb2 | |||
e11e0f0849 | |||
92a13854c3 | |||
cb90f19165 | |||
c1a9a5148a | |||
2555520d8c | |||
a424556da6 | |||
77137baf37 | |||
0ba9b51212 | |||
99716cee1a | |||
7d8f8388f5 | |||
4608a247e1 | |||
abc54428c6 | |||
74c1522be2 | |||
e200b7eba7 | |||
a0ba9fe3b9 | |||
fb1e2bab89 | |||
3a148a2879 | |||
5005a2f0c2 | |||
ef1685dc82 | |||
aae46c69dd | |||
8d6686bd1b | |||
ec727121c9 | |||
595fd692a6 | |||
c6832203ad | |||
ca4ac359d3 | |||
5ce523a3fb | |||
3f42a0d989 | |||
d9ae92dbc2 | |||
047ec9feca | |||
a763877d2a | |||
31f6eb4a5e | |||
7cf0f191be | |||
03b678145a | |||
694a50ea0c | |||
0da0842f62 | |||
cc355a9510 | |||
29b3b9f6ba | |||
ef04592efa | |||
5ac072b5e8 | |||
6c4789b59b | |||
4f926f7786 | |||
49b2209517 | |||
12e9ad6362 | |||
8168984286 | |||
8489f738dd | |||
f4c56fd797 | |||
1a5e55f175 | |||
8561d75907 | |||
39d26eca9f | |||
8a7aaa8c17 | |||
478c310743 | |||
d0b1a19918 | |||
0352144807 | |||
850675ced8 | |||
88213456f1 | |||
5bafed745d | |||
32eaa5c81c | |||
688432ae7b | |||
158f7ddadb | |||
f3e3759adc | |||
d0453f003c | |||
d5123ea314 | |||
2fa16d28bf | |||
b9f7ac3267 | |||
48a43bf190 | |||
a9c50d36a7 | |||
a6c57d83cd | |||
44d8a1d40c | |||
792f337c67 | |||
a6617d739a | |||
113c99e166 | |||
70783cd697 | |||
b2a59ce05d | |||
aa1833556a | |||
eb028ec487 | |||
bd401accf7 | |||
c480ed594d | |||
9d4ab9bdea | |||
e7d8f25959 | |||
85e7231b73 | |||
0a318447ea | |||
ce0e24efcd | |||
1efbb21d15 | |||
06d32ea181 | |||
e7bab7b322 | |||
00312cd11b | |||
50675524fc | |||
0937748190 | |||
e6e150dd86 | |||
05a4793487 | |||
e1f6efda03 | |||
c1fe084745 | |||
9a6d945553 | |||
c7e16020a0 | |||
da93c24121 | |||
695fe2a4c3 | |||
365ad9151c | |||
ed0c4c43ab | |||
70a286f90d | |||
55e5d8eee8 | |||
5afb4b1aa1 | |||
5dcd7263d0 | |||
fc115680c4 | |||
aa4aaf1b44 | |||
775e62f8ad | |||
d336531586 | |||
d629d82250 | |||
0d1e57c698 | |||
095dfc0436 | |||
e066941d93 | |||
d0ae4a68ad | |||
604c9014d0 | |||
c6bcbd0e07 | |||
f728fbd123 | |||
7949eb84fa | |||
b06b4a8a75 | |||
8257627487 | |||
00c38523ac | |||
7716ed1243 | |||
0f52820601 | |||
4652c4acc0 | |||
523c987722 | |||
55012c9b2f | |||
7f7db12431 | |||
0091863805 | |||
ce20535624 | |||
e07b829237 | |||
2808ff0f5d | |||
660db82197 | |||
e9aa6b82d2 | |||
9daecb947e | |||
93eeb0c1a6 | |||
a67e7cdef1 | |||
c2bc4ae35e | |||
a498707feb | |||
54df782eb4 | |||
946f3fd651 | |||
6215eccc37 | |||
5150c035be | |||
728fa8f5bb | |||
939eebe0fe | |||
24c17b9dcf | |||
c5910ad1ae | |||
9cb9d93622 | |||
1a890844ef | |||
8ecacbe622 | |||
6efa4123cf | |||
0353fe8435 | |||
f7eeefa226 | |||
6561d9f09c | |||
b6ad281a10 | |||
80737c21a5 | |||
c6315ea181 | |||
fcc33fc458 | |||
c712347781 | |||
a4c3d774ff | |||
f027c77a1e | |||
100df1e4aa | |||
bd3aeb92f1 | |||
e96d55a7e1 | |||
0e7d7675d3 | |||
13dbd0a6f5 | |||
a6c213b083 | |||
f492c0be1c | |||
23058d3a2c | |||
9cdf45de5e | |||
508ae60c18 | |||
167ddda2d4 | |||
d286e0d827 | |||
4450f17e8d | |||
f9332777dd | |||
83adb86988 | |||
3edc78ec2a | |||
598839407c | |||
40fd20a0cf | |||
8ef544cd0f | |||
c67440813e | |||
47ed9325ee | |||
d93b6a78e0 | |||
5d03060639 | |||
8047d72a35 | |||
977aa18d38 | |||
cc4c3ea67e | |||
81eb9d8f44 | |||
560a72944b | |||
6534d160e5 | |||
cac5fd6866 | |||
b21d5b6683 | |||
6e9dafebe0 | |||
09f2ae9213 | |||
88681d1849 | |||
921e72da13 | |||
577caa201b | |||
64de368ca5 | |||
a6739de9a4 | |||
5dc0a54ba2 | |||
e3206291bb | |||
6d37b57398 | |||
fe9f9ee19b | |||
7f0fd6312a | |||
97b2ff4ff9 | |||
d890f635e2 | |||
c8ee881b2c | |||
0442538bd5 | |||
f167e24c4f | |||
d9a4e3249d | |||
bdab064b38 | |||
c36e634b72 | |||
8218bec088 | |||
45ff766752 | |||
47c9fad545 | |||
e2ccfc8aed | |||
5cd4b71f2c | |||
2d240c8950 | |||
3438c187b1 | |||
28bfdb22b1 | |||
c2d658991c | |||
2536fd210a | |||
f23cc80add | |||
49296478ea | |||
2d72efbece | |||
6c7e76cded | |||
dc29f71549 | |||
7f39ebcf97 | |||
09df9a3a1d | |||
2fea68c37c | |||
b3355809e6 | |||
28f4df254d | |||
14f6a5ff64 | |||
4e23e74892 | |||
1f9b0c1bb0 | |||
6af22284b6 | |||
b2c61c7a4c | |||
19ee2cc038 | |||
4adfb2f9de | |||
33e6173e40 | |||
b44f07a9de | |||
44c6b14d7f | |||
14e78cb255 | |||
8cab8aa078 | |||
6de067272c | |||
4ace9346ee | |||
741c51aff4 | |||
531f7b1d37 | |||
eddff39719 | |||
8d1d4ac819 | |||
69dd0fd514 | |||
f44195bf99 | |||
b038aa664f | |||
f36a690e04 | |||
5849460ca5 | |||
c4e0c96268 | |||
7f8f8072d2 | |||
2fe93a3a09 | |||
207098910f | |||
a406c149bd | |||
239835cc36 | |||
47d18c8d0c | |||
601cb245db | |||
ec9e6c1d4b | |||
c1e0d9d81d | |||
160a6a0e75 | |||
04d6f21754 | |||
a8928020e7 | |||
67f35bba60 | |||
3b25dfc20f | |||
81e1da2bbc | |||
7d167f0463 | |||
900043a7af | |||
3233e73485 | |||
162720cba1 | |||
0341b2e01a | |||
5ee4765099 | |||
ab322c92e9 | |||
39a190116d | |||
5ea220e863 | |||
045878523f | |||
3cc29760f9 | |||
3f4eec9229 | |||
1365fa467a | |||
b1398fee2d | |||
ca5aa30e92 | |||
e72ecc3265 | |||
ab13b06738 | |||
4cf26ce551 | |||
3e1f5f0076 | |||
b5674622aa | |||
3ded39f6fc | |||
d8695d62b8 | |||
33f7d64e7e | |||
d3983edf11 | |||
a84391b583 | |||
9f83183d2c | |||
8652007906 | |||
29c18807d8 | |||
eb00b4e7b8 | |||
f16bee5927 | |||
61082619fe | |||
79126ebbd7 | |||
d87f04b76b | |||
da476ea4d7 | |||
0266c0c8b3 | |||
5863c346d0 | |||
b0087f2dfb | |||
97340b4ae8 | |||
7dcc5e1d29 | |||
240d830526 | |||
c1e7ed9034 | |||
8324f9c501 | |||
d715a61255 | |||
eaee7f601e | |||
042776d491 | |||
900f6b8af8 | |||
86ada0da5d | |||
3d59629f7a | |||
dffc00382a | |||
2dd9fc3469 | |||
cfd0cb37f5 | |||
d14557ac49 | |||
e188949ac0 | |||
d2bddb62bc | |||
b382f6bb85 | |||
16ccb39b36 | |||
60cc8a2401 | |||
11715864a4 | |||
a79febee92 | |||
554188e511 | |||
a628bdee49 | |||
873a2aae95 | |||
1fe01ff893 | |||
ceb0f11128 | |||
bf3562c9e0 | |||
7e5bf55e66 | |||
1251d61352 | |||
f2a58b5dcd | |||
d74f4aee61 | |||
0788b6462c | |||
26ee9e5d72 | |||
4c12a3c56b | |||
de767c90b9 | |||
be8066de17 | |||
7262c66c90 | |||
73ff552104 | |||
98920a485f | |||
4a2d95f64f | |||
c55b6f724e | |||
2ad40c4ba0 | |||
5cb64ad015 | |||
a60179eb0e | |||
2956777cf5 | |||
65842c7f30 | |||
b7b759f5e9 | |||
10594732ba | |||
36ee8bf5b7 | |||
3dbbe50b83 | |||
35d7bd493e | |||
e4ae43f182 | |||
cef5d3c416 | |||
34efa48c3e | |||
cba850251f | |||
9f25f88695 | |||
2043afadbb | |||
74503d1eaa | |||
c3a173128e | |||
6005955884 | |||
3aef093883 | |||
fb9ec24986 | |||
49899defa9 | |||
549d12b392 | |||
eff5ee9609 | |||
65f6f80303 | |||
93053d5077 | |||
4d53f8a122 | |||
9a3914660f | |||
961b4b07c4 | |||
0f6c68b1fc | |||
b528e6fdbb | |||
2018174ed5 | |||
935deeca2c | |||
8ac79020d6 | |||
c1972c7930 | |||
f686003f19 | |||
42a494a15b | |||
faa668550c | |||
cb797074cb | |||
ede195ce57 | |||
738dee1f0c | |||
7f0ea4f04c | |||
49d27e5849 | |||
03b9dfc60a | |||
433f8384a0 | |||
2c0b6356b6 | |||
c6c984c34c | |||
c84fb50087 | |||
79ce616781 | |||
e4a1817d7f | |||
2a69c89065 | |||
0899835fab | |||
cf5848491b | |||
33748e3233 | |||
cc0b6a2547 | |||
574dd8b16b |
@ -7,13 +7,14 @@ steps:
|
||||
- name: backend_check
|
||||
image: rust
|
||||
commands:
|
||||
- apt update && apt install -y cmake
|
||||
- rustup component add clippy
|
||||
- cd geneit_backend
|
||||
- cargo clippy -- -D warnings
|
||||
- cargo test
|
||||
|
||||
- name: app_deploy
|
||||
image: node:18
|
||||
image: node:23
|
||||
environment:
|
||||
AWS_ACCESS_KEY_ID:
|
||||
from_secret: AWS_ACCESS_KEY_ID
|
||||
@ -23,7 +24,7 @@ steps:
|
||||
commands:
|
||||
# Build website
|
||||
- cd geneit_app
|
||||
- npm install
|
||||
- npm install
|
||||
- GENERATE_SOURCEMAP=false npm run build
|
||||
# Install AWS
|
||||
- curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
|
||||
|
674
LICENSE
Normal file
674
LICENSE
Normal file
@ -0,0 +1,674 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<https://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
@ -1,7 +1,5 @@
|
||||
# GeneIT
|
||||
|
||||
WIP project
|
||||
|
||||
## Setup dev env
|
||||
1. Install prerequisites:
|
||||
1. docker
|
||||
@ -19,7 +17,7 @@ docker-compose up
|
||||
3. Install Diesel CLI:
|
||||
|
||||
```bash
|
||||
sudo apt install libpq5 libpq-dev
|
||||
sudo apt install libpq5 libpq-dev pkg-config libssl-dev cmake
|
||||
cargo install diesel_cli --no-default-features --features postgres
|
||||
```
|
||||
|
||||
@ -51,4 +49,4 @@ evan@qlik.example
|
||||
franklin@qlik.example
|
||||
```
|
||||
|
||||
Password: `Password1!`
|
||||
Password: `Password1!`
|
||||
|
@ -1 +1 @@
|
||||
REACT_APP_BACKEND=http://localhost:8000
|
||||
VITE_APP_BACKEND=http://localhost:8000
|
@ -1 +1 @@
|
||||
REACT_APP_BACKEND=https://geneit-backend.communiquons.org
|
||||
VITE_APP_BACKEND=https://geneit-backend.communiquons.org
|
||||
|
1
geneit_app/.gitignore
vendored
1
geneit_app/.gitignore
vendored
@ -10,6 +10,7 @@
|
||||
|
||||
# production
|
||||
/build
|
||||
/dist
|
||||
|
||||
# misc
|
||||
.DS_Store
|
||||
|
28
geneit_app/eslint.config.js
Normal file
28
geneit_app/eslint.config.js
Normal file
@ -0,0 +1,28 @@
|
||||
import js from '@eslint/js'
|
||||
import globals from 'globals'
|
||||
import reactHooks from 'eslint-plugin-react-hooks'
|
||||
import reactRefresh from 'eslint-plugin-react-refresh'
|
||||
import tseslint from 'typescript-eslint'
|
||||
|
||||
export default tseslint.config(
|
||||
{ ignores: ['dist'] },
|
||||
{
|
||||
extends: [js.configs.recommended, ...tseslint.configs.recommended],
|
||||
files: ['**/*.{ts,tsx}'],
|
||||
languageOptions: {
|
||||
ecmaVersion: 2020,
|
||||
globals: globals.browser,
|
||||
},
|
||||
plugins: {
|
||||
'react-hooks': reactHooks,
|
||||
'react-refresh': reactRefresh,
|
||||
},
|
||||
rules: {
|
||||
...reactHooks.configs.recommended.rules,
|
||||
'react-refresh/only-export-components': [
|
||||
'warn',
|
||||
{ allowConstantExport: true },
|
||||
],
|
||||
},
|
||||
},
|
||||
)
|
@ -2,25 +2,25 @@
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
|
||||
<link rel="icon" href="/favicon.ico" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<meta name="theme-color" content="#000000" />
|
||||
<meta
|
||||
name="description"
|
||||
content="Web site created using create-react-app"
|
||||
/>
|
||||
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
|
||||
<link rel="apple-touch-icon" href="/logo192.png" />
|
||||
<!--
|
||||
manifest.json provides metadata used when your web app is installed on a
|
||||
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
|
||||
-->
|
||||
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
|
||||
<link rel="manifest" href="/manifest.json" />
|
||||
<!--
|
||||
Notice the use of %PUBLIC_URL% in the tags above.
|
||||
Notice the use of in the tags above.
|
||||
It will be replaced with the URL of the `public` folder during the build.
|
||||
Only files inside the `public` folder can be referenced from the HTML.
|
||||
|
||||
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
|
||||
Unlike "/favicon.ico" or "favicon.ico", "/favicon.ico" will
|
||||
work correctly both with client-side routing and a non-root public URL.
|
||||
Learn how to configure a non-root public URL by running `npm run build`.
|
||||
-->
|
||||
@ -39,5 +39,7 @@
|
||||
To begin the development, run `npm start` or `yarn start`.
|
||||
To create a production bundle, use `npm run build` or `yarn build`.
|
||||
-->
|
||||
|
||||
<script type="module" src="/src/index.tsx"></script>
|
||||
</body>
|
||||
</html>
|
17110
geneit_app/package-lock.json
generated
17110
geneit_app/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -2,61 +2,55 @@
|
||||
"name": "geneit_app",
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"@babel/plugin-proposal-private-property-in-object": "^7.21.11",
|
||||
"@emotion/react": "^11.11.0",
|
||||
"@emotion/styled": "^11.11.0",
|
||||
"@fontsource/roboto": "^5.0.2",
|
||||
"@mdi/js": "^7.2.96",
|
||||
"@mdi/react": "^1.6.1",
|
||||
"@mui/icons-material": "^5.11.16",
|
||||
"@mui/lab": "^5.0.0-alpha.140",
|
||||
"@mui/material": "^5.14.5",
|
||||
"@mui/x-data-grid": "^6.9.2",
|
||||
"@testing-library/jest-dom": "^5.16.5",
|
||||
"@testing-library/react": "^13.4.0",
|
||||
"@testing-library/user-event": "^13.5.0",
|
||||
"@types/jest": "^27.5.2",
|
||||
"@types/node": "^16.18.34",
|
||||
"@types/react": "^18.2.8",
|
||||
"@types/react-dom": "^18.2.4",
|
||||
"date-and-time": "^3.0.1",
|
||||
"email-validator": "^2.0.4",
|
||||
"family-chart": "^0.0.0-beta-1",
|
||||
"filesize": "^10.0.9",
|
||||
"jspdf": "^2.5.1",
|
||||
"react": "^18.2.0",
|
||||
"react-dom": "^18.2.0",
|
||||
"react-easy-crop": "^5.0.0",
|
||||
"react-router-dom": "^6.11.2",
|
||||
"react-scripts": "^5.0.1",
|
||||
"react-zoom-pan-pinch": "^3.1.0",
|
||||
"svg2pdf.js": "^2.2.2",
|
||||
"typescript": "^4.9.5",
|
||||
"web-vitals": "^2.1.4"
|
||||
},
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"start": "react-scripts start",
|
||||
"build": "react-scripts build",
|
||||
"test": "react-scripts test",
|
||||
"eject": "react-scripts eject"
|
||||
"dev": "vite",
|
||||
"build": "tsc -b && vite build",
|
||||
"lint": "eslint .",
|
||||
"preview": "vite preview"
|
||||
},
|
||||
"eslintConfig": {
|
||||
"extends": [
|
||||
"react-app",
|
||||
"react-app/jest"
|
||||
]
|
||||
"dependencies": {
|
||||
"@emotion/react": "^11.14.0",
|
||||
"@emotion/styled": "^11.14.0",
|
||||
"@fontsource/roboto": "^5.2.6",
|
||||
"@fullcalendar/core": "^6.1.17",
|
||||
"@fullcalendar/daygrid": "^6.1.17",
|
||||
"@fullcalendar/interaction": "^6.1.17",
|
||||
"@fullcalendar/list": "^6.1.17",
|
||||
"@fullcalendar/react": "^6.1.17",
|
||||
"@mdi/js": "^7.4.47",
|
||||
"@mdi/react": "^1.6.1",
|
||||
"@mui/icons-material": "^7.0.2",
|
||||
"@mui/lab": "^7.0.0-beta.14",
|
||||
"@mui/material": "^7.0.2",
|
||||
"@mui/x-data-grid": "^7.29.6",
|
||||
"@mui/x-date-pickers": "^7.29.4",
|
||||
"@mui/x-tree-view": "^7.29.1",
|
||||
"date-and-time": "^3.6.0",
|
||||
"dayjs": "^1.11.13",
|
||||
"email-validator": "^2.0.4",
|
||||
"filesize": "^10.1.6",
|
||||
"jspdf": "^3.0.1",
|
||||
"mui-color-input": "^7.0.0",
|
||||
"react": "^19.0.0",
|
||||
"react-dom": "^19.0.0",
|
||||
"react-easy-crop": "^5.4.2",
|
||||
"react-qr-code": "^2.0.16",
|
||||
"react-router-dom": "^7.4.0",
|
||||
"react-zoom-pan-pinch": "^3.7.0",
|
||||
"svg2pdf.js": "^2.5.0"
|
||||
},
|
||||
"browserslist": {
|
||||
"production": [
|
||||
">0.2%",
|
||||
"not dead",
|
||||
"not op_mini all"
|
||||
],
|
||||
"development": [
|
||||
"last 1 chrome version",
|
||||
"last 1 firefox version",
|
||||
"last 1 safari version"
|
||||
]
|
||||
"devDependencies": {
|
||||
"@eslint/js": "^9.28.0",
|
||||
"@types/react": "^19.0.12",
|
||||
"@types/react-dom": "^19.0.4",
|
||||
"@vitejs/plugin-react": "^4.4.1",
|
||||
"eslint": "^9.28.0",
|
||||
"eslint-plugin-react-hooks": "^5.2.0",
|
||||
"eslint-plugin-react-refresh": "^0.4.20",
|
||||
"globals": "^16.0.0",
|
||||
"typescript": "^5.8.3",
|
||||
"typescript-eslint": "^8.34.1",
|
||||
"vite": "^6.2.3"
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"short_name": "GeneIT",
|
||||
"name": "La généalogie de votre famille simplifiée",
|
||||
"name": "La vie informatique de votre famille simplifiée",
|
||||
"icons": [
|
||||
{
|
||||
"src": "favicon.ico",
|
||||
|
@ -16,26 +16,33 @@ import { NewAccountRoute } from "./routes/auth/NewAccountRoute";
|
||||
import { OIDCCbRoute } from "./routes/auth/OIDCCbRoute";
|
||||
import { PasswordForgottenRoute } from "./routes/auth/PasswordForgottenRoute";
|
||||
import { ResetPasswordRoute } from "./routes/auth/ResetPasswordRoute";
|
||||
import { FamilyHomeRoute } from "./routes/family/FamilyHomeRoute";
|
||||
import {
|
||||
FamilyCreateMemberRoute,
|
||||
FamilyEditMemberRoute,
|
||||
FamilyMemberRoute,
|
||||
} from "./routes/family/FamilyMemberRoute";
|
||||
import { FamilySettingsRoute } from "./routes/family/FamilySettingsRoute";
|
||||
import { FamilyUsersListRoute } from "./routes/family/FamilyUsersListRoute";
|
||||
import { BaseAuthenticatedPage } from "./widgets/BaseAuthenticatedPage";
|
||||
import { BaseFamilyRoute } from "./widgets/BaseFamilyRoute";
|
||||
import { BaseLoginPage } from "./widgets/BaseLoginpage";
|
||||
import { FamilyMembersListRoute } from "./routes/family/FamilyMembersListRoute";
|
||||
import { AccommodationsHomeRoute } from "./routes/family/accommodations/AccommodationsHomeRoute";
|
||||
import { AccommodationsReservationsRoute } from "./routes/family/accommodations/AccommodationsReservationsRoute";
|
||||
import { AccommodationsSettingsRoute } from "./routes/family/accommodations/AccommodationsSettingsRoute";
|
||||
import {
|
||||
FamilyCoupleRoute,
|
||||
FamilyCreateCoupleRoute,
|
||||
FamilyEditCoupleRoute,
|
||||
} from "./routes/family/FamilyCoupleRoute";
|
||||
import { FamilyCouplesListRoute } from "./routes/family/FamilyCouplesListRoute";
|
||||
import { FamilyTreeRoute } from "./routes/family/FamilyTreeRoute";
|
||||
import { FamilyMemberTreeRoute } from "./routes/family/FamilyMemberTreeRoute";
|
||||
} from "./routes/family/genealogy/FamilyCoupleRoute";
|
||||
import { FamilyCouplesListRoute } from "./routes/family/genealogy/FamilyCouplesListRoute";
|
||||
import { FamilyHomeRoute } from "./routes/family/genealogy/FamilyHomeRoute";
|
||||
import {
|
||||
FamilyCreateMemberRoute,
|
||||
FamilyEditMemberRoute,
|
||||
FamilyMemberRoute,
|
||||
} from "./routes/family/genealogy/FamilyMemberRoute";
|
||||
import { FamilyMemberTreeRoute } from "./routes/family/genealogy/FamilyMemberTreeRoute";
|
||||
import { FamilyMembersListRoute } from "./routes/family/genealogy/FamilyMembersListRoute";
|
||||
import { FamilyTreeRoute } from "./routes/family/genealogy/FamilyTreeRoute";
|
||||
import { GenalogySettingsRoute } from "./routes/family/genealogy/GenalogySettingsRoute";
|
||||
import { GenealogyHomeRoute } from "./routes/family/genealogy/GenealogyHomeRoute";
|
||||
import { BaseAuthenticatedPage } from "./widgets/BaseAuthenticatedPage";
|
||||
import { BaseFamilyRoute } from "./widgets/BaseFamilyRoute";
|
||||
import { BaseLoginPage } from "./widgets/BaseLoginpage";
|
||||
import { BaseAccommodationsRoute } from "./widgets/accommodations/BaseAccommodationsRoute";
|
||||
import { BaseGenealogyRoute } from "./widgets/genealogy/BaseGenealogyRoute";
|
||||
|
||||
interface AuthContext {
|
||||
signedIn: boolean;
|
||||
@ -52,7 +59,10 @@ export function App(): React.ReactElement {
|
||||
|
||||
const context: AuthContext = {
|
||||
signedIn: signedIn,
|
||||
setSignedIn: (s) => setSignedIn(s),
|
||||
setSignedIn: (s) => {
|
||||
location.reload();
|
||||
setSignedIn(s);
|
||||
},
|
||||
};
|
||||
|
||||
const router = createBrowserRouter(
|
||||
@ -67,33 +77,61 @@ export function App(): React.ReactElement {
|
||||
<Route path="family/:familyId/*" element={<BaseFamilyRoute />}>
|
||||
<Route path="" element={<FamilyHomeRoute />} />
|
||||
|
||||
<Route path="members" element={<FamilyMembersListRoute />} />
|
||||
<Route
|
||||
path="member/create"
|
||||
element={<FamilyCreateMemberRoute />}
|
||||
/>
|
||||
<Route path="member/:memberId" element={<FamilyMemberRoute />} />
|
||||
<Route
|
||||
path="member/:memberId/edit"
|
||||
element={<FamilyEditMemberRoute />}
|
||||
/>
|
||||
<Route path="genealogy/*" element={<BaseGenealogyRoute />}>
|
||||
<Route path="" element={<GenealogyHomeRoute />} />
|
||||
|
||||
<Route path="couples" element={<FamilyCouplesListRoute />} />
|
||||
<Route
|
||||
path="couple/create"
|
||||
element={<FamilyCreateCoupleRoute />}
|
||||
/>
|
||||
<Route path="couple/:coupleId" element={<FamilyCoupleRoute />} />
|
||||
<Route
|
||||
path="couple/:coupleId/edit"
|
||||
element={<FamilyEditCoupleRoute />}
|
||||
/>
|
||||
<Route path="members" element={<FamilyMembersListRoute />} />
|
||||
<Route
|
||||
path="member/create"
|
||||
element={<FamilyCreateMemberRoute />}
|
||||
/>
|
||||
<Route
|
||||
path="member/:memberId"
|
||||
element={<FamilyMemberRoute />}
|
||||
/>
|
||||
<Route
|
||||
path="member/:memberId/edit"
|
||||
element={<FamilyEditMemberRoute />}
|
||||
/>
|
||||
|
||||
<Route path="couples" element={<FamilyCouplesListRoute />} />
|
||||
<Route
|
||||
path="couple/create"
|
||||
element={<FamilyCreateCoupleRoute />}
|
||||
/>
|
||||
<Route
|
||||
path="couple/:coupleId"
|
||||
element={<FamilyCoupleRoute />}
|
||||
/>
|
||||
<Route
|
||||
path="couple/:coupleId/edit"
|
||||
element={<FamilyEditCoupleRoute />}
|
||||
/>
|
||||
|
||||
<Route path="tree" element={<FamilyTreeRoute />} />
|
||||
<Route
|
||||
path="tree/:memberId"
|
||||
element={<FamilyMemberTreeRoute />}
|
||||
/>
|
||||
<Route path="settings" element={<GenalogySettingsRoute />} />
|
||||
<Route path="*" element={<NotFoundRoute />} />
|
||||
</Route>
|
||||
|
||||
<Route path="tree" element={<FamilyTreeRoute />} />
|
||||
<Route
|
||||
path="tree/:memberId"
|
||||
element={<FamilyMemberTreeRoute />}
|
||||
/>
|
||||
path="accommodations/*"
|
||||
element={<BaseAccommodationsRoute />}
|
||||
>
|
||||
<Route path="" element={<AccommodationsHomeRoute />} />
|
||||
<Route
|
||||
path="reservations"
|
||||
element={<AccommodationsReservationsRoute />}
|
||||
/>
|
||||
<Route
|
||||
path="settings"
|
||||
element={<AccommodationsSettingsRoute />}
|
||||
/>
|
||||
<Route path="*" element={<NotFoundRoute />} />
|
||||
</Route>
|
||||
|
||||
<Route path="settings" element={<FamilySettingsRoute />} />
|
||||
<Route path="users" element={<FamilyUsersListRoute />} />
|
||||
|
@ -16,7 +16,7 @@ export class APIClient {
|
||||
* Get backend URL
|
||||
*/
|
||||
static backendURL(): string {
|
||||
const URL = process.env.REACT_APP_BACKEND ?? "";
|
||||
const URL = import.meta.env.VITE_APP_BACKEND ?? "";
|
||||
if (URL.length === 0) throw new Error("Backend URL undefined!");
|
||||
return URL;
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { APIClient } from "./ApiClient";
|
||||
import { Couple } from "./CoupleApi";
|
||||
import { Member } from "./MemberApi";
|
||||
import { Couple } from "./genealogy/CoupleApi";
|
||||
import { Member } from "./genealogy/MemberApi";
|
||||
|
||||
interface FamilyAPI {
|
||||
user_id: number;
|
||||
@ -60,7 +60,8 @@ export class Family implements FamilyAPI {
|
||||
*/
|
||||
memberURL(member: Member, edit?: boolean): string {
|
||||
return (
|
||||
`/family/${this.family_id}/member/${member.id}` + (edit ? "/edit" : "")
|
||||
`/family/${this.family_id}/genealogy/member/${member.id}` +
|
||||
(edit ? "/edit" : "")
|
||||
);
|
||||
}
|
||||
|
||||
@ -68,7 +69,7 @@ export class Family implements FamilyAPI {
|
||||
* Get family tree URL for member
|
||||
*/
|
||||
familyTreeURL(member: Member | number): string {
|
||||
return `/family/${this.family_id}/tree/${
|
||||
return `/family/${this.family_id}/genealogy/tree/${
|
||||
typeof member === "number" ? member : member.id
|
||||
}`;
|
||||
}
|
||||
@ -78,16 +79,21 @@ export class Family implements FamilyAPI {
|
||||
*/
|
||||
coupleURL(member: Couple, edit?: boolean): string {
|
||||
return (
|
||||
`/family/${this.family_id}/couple/${member.id}` + (edit ? "/edit" : "")
|
||||
`/family/${this.family_id}/genealogy/couple/${member.id}` +
|
||||
(edit ? "/edit" : "")
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export class ExtendedFamilyInfo extends Family {
|
||||
public disable_couple_photos: boolean;
|
||||
public enable_genealogy: boolean;
|
||||
public enable_accommodations: boolean;
|
||||
constructor(p: any) {
|
||||
super(p);
|
||||
this.disable_couple_photos = p.disable_couple_photos;
|
||||
this.enable_genealogy = p.enable_genealogy;
|
||||
this.enable_accommodations = p.enable_accommodations;
|
||||
}
|
||||
}
|
||||
|
||||
@ -229,14 +235,18 @@ export class FamilyApi {
|
||||
*/
|
||||
static async UpdateFamily(settings: {
|
||||
id: number;
|
||||
name: string;
|
||||
disable_couple_photos: boolean;
|
||||
name?: string;
|
||||
enable_genealogy?: boolean;
|
||||
enable_accommodations?: boolean;
|
||||
disable_couple_photos?: boolean;
|
||||
}): Promise<void> {
|
||||
await APIClient.exec({
|
||||
method: "PATCH",
|
||||
uri: `/family/${settings.id}`,
|
||||
jsonData: {
|
||||
name: settings.name,
|
||||
enable_genealogy: settings.enable_genealogy,
|
||||
enable_accommodations: settings.enable_accommodations,
|
||||
disable_couple_photos: settings.disable_couple_photos,
|
||||
},
|
||||
});
|
||||
|
@ -32,6 +32,9 @@ interface Constraints {
|
||||
member_country: LenConstraint;
|
||||
member_sex: LenConstraint;
|
||||
member_note: LenConstraint;
|
||||
accommodation_name_len: LenConstraint;
|
||||
accommodation_description_len: LenConstraint;
|
||||
accommodation_calendar_name_len: LenConstraint;
|
||||
}
|
||||
|
||||
interface OIDCProvider {
|
||||
|
124
geneit_app/src/api/accommodations/AccommodationListApi.tsx
Normal file
124
geneit_app/src/api/accommodations/AccommodationListApi.tsx
Normal file
@ -0,0 +1,124 @@
|
||||
import { APIClient } from "../ApiClient";
|
||||
import { Family } from "../FamilyApi";
|
||||
|
||||
export interface Accommodation {
|
||||
id: number;
|
||||
family_id: number;
|
||||
time_create: number;
|
||||
time_update: number;
|
||||
name: string;
|
||||
need_validation: boolean;
|
||||
description?: string;
|
||||
color?: string;
|
||||
open_to_reservations: boolean;
|
||||
}
|
||||
|
||||
export class AccommodationsList {
|
||||
private list: Accommodation[];
|
||||
private map: Map<number, Accommodation>;
|
||||
|
||||
constructor(list: Accommodation[]) {
|
||||
this.list = list;
|
||||
this.map = new Map();
|
||||
|
||||
for (const m of list) {
|
||||
this.map.set(m.id, m);
|
||||
}
|
||||
|
||||
this.list.sort((a, b) =>
|
||||
a.name.toLowerCase().localeCompare(b.name.toLocaleLowerCase())
|
||||
);
|
||||
}
|
||||
|
||||
public get isEmpty(): boolean {
|
||||
return this.list.length === 0;
|
||||
}
|
||||
|
||||
public get size(): number {
|
||||
return this.list.length;
|
||||
}
|
||||
|
||||
public get fullList(): Accommodation[] {
|
||||
return this.list;
|
||||
}
|
||||
|
||||
filter(predicate: (m: Accommodation) => boolean): Accommodation[] {
|
||||
return this.list.filter(predicate);
|
||||
}
|
||||
|
||||
get openToReservationList(): Accommodation[] {
|
||||
return this.filter((a) => a.open_to_reservations);
|
||||
}
|
||||
|
||||
get(id: number): Accommodation | undefined {
|
||||
return this.map.get(id);
|
||||
}
|
||||
}
|
||||
|
||||
export interface UpdateAccommodation {
|
||||
name: string;
|
||||
need_validation: boolean;
|
||||
description?: string;
|
||||
color?: string;
|
||||
open_to_reservations: boolean;
|
||||
}
|
||||
|
||||
export class AccommodationListApi {
|
||||
/**
|
||||
* Get the list of accommodation of a family
|
||||
*/
|
||||
static async GetListOfFamily(family: Family): Promise<AccommodationsList> {
|
||||
const data = (
|
||||
await APIClient.exec({
|
||||
method: "GET",
|
||||
uri: `/family/${family.family_id}/accommodations/list/list`,
|
||||
})
|
||||
).data;
|
||||
|
||||
return new AccommodationsList(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new accommodation
|
||||
*/
|
||||
static async Create(
|
||||
family: Family,
|
||||
accommodation: UpdateAccommodation
|
||||
): Promise<Accommodation> {
|
||||
return (
|
||||
await APIClient.exec({
|
||||
method: "POST",
|
||||
uri: `/family/${family.family_id}/accommodations/list/create`,
|
||||
jsonData: accommodation,
|
||||
})
|
||||
).data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update an accommodation
|
||||
*/
|
||||
static async Update(
|
||||
accommodation: Accommodation,
|
||||
update: UpdateAccommodation
|
||||
): Promise<Accommodation> {
|
||||
return (
|
||||
await APIClient.exec({
|
||||
method: "PUT",
|
||||
uri: `/family/${accommodation.family_id}/accommodations/list/${accommodation.id}`,
|
||||
jsonData: update,
|
||||
})
|
||||
).data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete an accommodation
|
||||
*/
|
||||
static async Delete(accommodation: Accommodation): Promise<Accommodation> {
|
||||
return (
|
||||
await APIClient.exec({
|
||||
method: "DELETE",
|
||||
uri: `/family/${accommodation.family_id}/accommodations/list/${accommodation.id}`,
|
||||
})
|
||||
).data;
|
||||
}
|
||||
}
|
@ -0,0 +1,69 @@
|
||||
import { APIClient } from "../ApiClient";
|
||||
import { Family } from "../FamilyApi";
|
||||
|
||||
export interface NewCalendarURL {
|
||||
accommodation_id?: number;
|
||||
name: string;
|
||||
}
|
||||
|
||||
export interface AccommodationCalendarURL {
|
||||
id: number;
|
||||
family_id: number;
|
||||
accommodation_id: number;
|
||||
user_id: number;
|
||||
name: string;
|
||||
token: string;
|
||||
time_create: number;
|
||||
time_used: number;
|
||||
}
|
||||
|
||||
export class AccommodationsCalendarURLApi {
|
||||
/**
|
||||
* Create a new accommodation calendar URL
|
||||
*/
|
||||
static async Create(
|
||||
family: Family,
|
||||
calendar: NewCalendarURL
|
||||
): Promise<AccommodationCalendarURL> {
|
||||
return (
|
||||
await APIClient.exec({
|
||||
method: "POST",
|
||||
uri: `/family/${family.family_id}/accommodations/reservations_calendars/create`,
|
||||
jsonData: calendar,
|
||||
})
|
||||
).data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get accommodation calendar URL route
|
||||
*/
|
||||
static CalendarURL(c: AccommodationCalendarURL): string {
|
||||
return `${APIClient.backendURL()}/acccommodations_calendar/${c.token}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get accommodations calendars list
|
||||
*/
|
||||
static async GetList(family: Family): Promise<AccommodationCalendarURL[]> {
|
||||
return (
|
||||
await APIClient.exec({
|
||||
method: "GET",
|
||||
uri: `/family/${family.family_id}/accommodations/reservations_calendars/list`,
|
||||
})
|
||||
).data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete an accommodation calendar
|
||||
*/
|
||||
static async Delete(
|
||||
calendar: AccommodationCalendarURL
|
||||
): Promise<AccommodationCalendarURL> {
|
||||
return (
|
||||
await APIClient.exec({
|
||||
method: "DELETE",
|
||||
uri: `/family/${calendar.family_id}/accommodations/reservations_calendars/${calendar.id}`,
|
||||
})
|
||||
).data;
|
||||
}
|
||||
}
|
@ -0,0 +1,175 @@
|
||||
import { APIClient } from "../ApiClient";
|
||||
import { Family } from "../FamilyApi";
|
||||
import { Accommodation } from "./AccommodationListApi";
|
||||
|
||||
export enum ValidateResaResult {
|
||||
Success,
|
||||
Error,
|
||||
Conflict,
|
||||
}
|
||||
|
||||
export interface AccommodationReservation {
|
||||
id: number;
|
||||
family_id: number;
|
||||
accommodation_id: number;
|
||||
user_id: number;
|
||||
time_create: number;
|
||||
time_update: number;
|
||||
reservation_start: number;
|
||||
reservation_end: number;
|
||||
validated?: boolean;
|
||||
}
|
||||
|
||||
export class AccommodationsReservationsList {
|
||||
private list: AccommodationReservation[];
|
||||
private map: Map<number, AccommodationReservation>;
|
||||
|
||||
constructor(list: AccommodationReservation[]) {
|
||||
this.list = list;
|
||||
this.map = new Map();
|
||||
|
||||
for (const m of list) {
|
||||
this.map.set(m.id, m);
|
||||
}
|
||||
|
||||
this.list.sort((a, b) => a.reservation_start - b.reservation_start);
|
||||
}
|
||||
|
||||
public get isEmpty(): boolean {
|
||||
return this.list.length === 0;
|
||||
}
|
||||
|
||||
public get size(): number {
|
||||
return this.list.length;
|
||||
}
|
||||
|
||||
public get fullList(): AccommodationReservation[] {
|
||||
return this.list;
|
||||
}
|
||||
|
||||
filter(
|
||||
predicate: (m: AccommodationReservation) => boolean
|
||||
): AccommodationReservation[] {
|
||||
return this.list.filter(predicate);
|
||||
}
|
||||
|
||||
forAccommodation(id: number): AccommodationReservation[] {
|
||||
return this.filter((a) => a.accommodation_id === id);
|
||||
}
|
||||
|
||||
get(id: number): AccommodationReservation | undefined {
|
||||
return this.map.get(id);
|
||||
}
|
||||
}
|
||||
|
||||
export interface UpdateAccommodationReservation {
|
||||
start: number;
|
||||
end: number;
|
||||
accommodation_id: number;
|
||||
reservation_id?: number;
|
||||
}
|
||||
|
||||
export class AccommodationsReservationsApi {
|
||||
/**
|
||||
* Create a new reservation
|
||||
*/
|
||||
static async Create(
|
||||
family: Family,
|
||||
reservation: UpdateAccommodationReservation
|
||||
): Promise<AccommodationReservation> {
|
||||
return (
|
||||
await APIClient.exec({
|
||||
method: "POST",
|
||||
uri: `/family/${family.family_id}/accommodations/reservations/accommodation/${reservation.accommodation_id}/create`,
|
||||
jsonData: {
|
||||
start: reservation.start,
|
||||
end: reservation.end,
|
||||
},
|
||||
})
|
||||
).data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the entire list of accommodations of a family
|
||||
*/
|
||||
static async FullListOfFamily(
|
||||
family: Family
|
||||
): Promise<AccommodationsReservationsList> {
|
||||
const data = (
|
||||
await APIClient.exec({
|
||||
method: "GET",
|
||||
uri: `/family/${family.family_id}/accommodations/reservations/full_list`,
|
||||
})
|
||||
).data;
|
||||
|
||||
return new AccommodationsReservationsList(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the reservations of a given time interval for an accommodation
|
||||
*/
|
||||
static async ReservationsForInterval(
|
||||
family: Family,
|
||||
accommodation: Accommodation,
|
||||
start: number,
|
||||
end: number
|
||||
): Promise<AccommodationsReservationsList> {
|
||||
const data = (
|
||||
await APIClient.exec({
|
||||
method: "GET",
|
||||
uri: `/family/${family.family_id}/accommodations/reservations/accommodation/${accommodation.id}/for_interval?start=${start}&end=${end}`,
|
||||
})
|
||||
).data;
|
||||
|
||||
return new AccommodationsReservationsList(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update a reservation
|
||||
*/
|
||||
static async Update(
|
||||
family: Family,
|
||||
r: UpdateAccommodationReservation
|
||||
): Promise<void> {
|
||||
await APIClient.exec({
|
||||
method: "PATCH",
|
||||
uri: `/family/${family.family_id}/accommodations/reservation/${r.reservation_id}`,
|
||||
jsonData: {
|
||||
start: r.start,
|
||||
end: r.end,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a reservation
|
||||
*/
|
||||
static async Delete(r: AccommodationReservation): Promise<void> {
|
||||
await APIClient.exec({
|
||||
method: "DELETE",
|
||||
uri: `/family/${r.family_id}/accommodations/reservation/${r.id}`,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate or reject a reservation request
|
||||
*/
|
||||
static async Validate(
|
||||
r: AccommodationReservation,
|
||||
accept: boolean
|
||||
): Promise<ValidateResaResult> {
|
||||
const res = await APIClient.exec({
|
||||
method: "POST",
|
||||
uri: `/family/${r.family_id}/accommodations/reservation/${r.id}/validate`,
|
||||
jsonData: {
|
||||
validate: accept,
|
||||
},
|
||||
allowFail: true,
|
||||
});
|
||||
|
||||
if (res.status >= 200 && res.status <= 299)
|
||||
return ValidateResaResult.Success;
|
||||
if (res.status === 409) return ValidateResaResult.Conflict;
|
||||
return ValidateResaResult.Error;
|
||||
}
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
import { APIClient } from "./ApiClient";
|
||||
import { APIClient } from "../ApiClient";
|
||||
import { DateValue, Member } from "./MemberApi";
|
||||
import { ServerApi } from "./ServerApi";
|
||||
import { ServerApi } from "../ServerApi";
|
||||
|
||||
interface CoupleApiInterface {
|
||||
id: number;
|
||||
@ -161,7 +161,7 @@ export class CoupleApi {
|
||||
*/
|
||||
static async Create(m: Couple): Promise<Couple> {
|
||||
const res = await APIClient.exec({
|
||||
uri: `/family/${m.family_id}/couple/create`,
|
||||
uri: `/family/${m.family_id}/genealogy/couple/create`,
|
||||
method: "POST",
|
||||
jsonData: m,
|
||||
});
|
||||
@ -177,7 +177,7 @@ export class CoupleApi {
|
||||
couple_id: number
|
||||
): Promise<Couple> {
|
||||
const res = await APIClient.exec({
|
||||
uri: `/family/${family_id}/couple/${couple_id}`,
|
||||
uri: `/family/${family_id}/genealogy/couple/${couple_id}`,
|
||||
method: "GET",
|
||||
});
|
||||
|
||||
@ -189,7 +189,7 @@ export class CoupleApi {
|
||||
*/
|
||||
static async GetEntireList(family_id: number): Promise<CouplesList> {
|
||||
const res = await APIClient.exec({
|
||||
uri: `/family/${family_id}/couples`,
|
||||
uri: `/family/${family_id}/genealogy/couples`,
|
||||
method: "GET",
|
||||
});
|
||||
|
||||
@ -201,7 +201,7 @@ export class CoupleApi {
|
||||
*/
|
||||
static async Update(m: Couple): Promise<void> {
|
||||
await APIClient.exec({
|
||||
uri: `/family/${m.family_id}/couple/${m.id}`,
|
||||
uri: `/family/${m.family_id}/genealogy/couple/${m.id}`,
|
||||
method: "PUT",
|
||||
jsonData: m,
|
||||
});
|
||||
@ -214,7 +214,7 @@ export class CoupleApi {
|
||||
const fd = new FormData();
|
||||
fd.append("photo", b);
|
||||
await APIClient.exec({
|
||||
uri: `/family/${m.family_id}/couple/${m.id}/photo`,
|
||||
uri: `/family/${m.family_id}/genealogy/couple/${m.id}/photo`,
|
||||
method: "PUT",
|
||||
formData: fd,
|
||||
});
|
||||
@ -225,7 +225,7 @@ export class CoupleApi {
|
||||
*/
|
||||
static async RemoveCouplePhoto(m: Couple): Promise<void> {
|
||||
await APIClient.exec({
|
||||
uri: `/family/${m.family_id}/couple/${m.id}/photo`,
|
||||
uri: `/family/${m.family_id}/genealogy/couple/${m.id}/photo`,
|
||||
method: "DELETE",
|
||||
});
|
||||
}
|
||||
@ -235,7 +235,7 @@ export class CoupleApi {
|
||||
*/
|
||||
static async Delete(m: Couple): Promise<void> {
|
||||
await APIClient.exec({
|
||||
uri: `/family/${m.family_id}/couple/${m.id}`,
|
||||
uri: `/family/${m.family_id}/genealogy/couple/${m.id}`,
|
||||
method: "DELETE",
|
||||
});
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
import { APIClient } from "./ApiClient";
|
||||
import { APIClient } from "../ApiClient";
|
||||
|
||||
/**
|
||||
* Data management api client
|
||||
@ -9,7 +9,7 @@ export class DataApi {
|
||||
*/
|
||||
static async ExportData(family_id: number): Promise<Blob> {
|
||||
const res = await APIClient.exec({
|
||||
uri: `/family/${family_id}/data/export`,
|
||||
uri: `/family/${family_id}/genealogy/data/export`,
|
||||
method: "GET",
|
||||
});
|
||||
return res.data;
|
||||
@ -22,7 +22,7 @@ export class DataApi {
|
||||
const fd = new FormData();
|
||||
fd.append("archive", archive);
|
||||
const res = await APIClient.exec({
|
||||
uri: `/family/${family_id}/data/import`,
|
||||
uri: `/family/${family_id}/genealogy/data/import`,
|
||||
method: "PUT",
|
||||
formData: fd,
|
||||
});
|
@ -1,4 +1,4 @@
|
||||
import { APIClient } from "./ApiClient";
|
||||
import { APIClient } from "../ApiClient";
|
||||
import { Couple } from "./CoupleApi";
|
||||
|
||||
export type Sex = "M" | "F";
|
||||
@ -278,7 +278,7 @@ export class MemberApi {
|
||||
*/
|
||||
static async Create(m: Member): Promise<Member> {
|
||||
const res = await APIClient.exec({
|
||||
uri: `/family/${m.family_id}/member/create`,
|
||||
uri: `/family/${m.family_id}/genealogy/member/create`,
|
||||
method: "POST",
|
||||
jsonData: m,
|
||||
});
|
||||
@ -294,7 +294,7 @@ export class MemberApi {
|
||||
member_id: number
|
||||
): Promise<Member> {
|
||||
const res = await APIClient.exec({
|
||||
uri: `/family/${family_id}/member/${member_id}`,
|
||||
uri: `/family/${family_id}/genealogy/member/${member_id}`,
|
||||
method: "GET",
|
||||
});
|
||||
|
||||
@ -306,7 +306,7 @@ export class MemberApi {
|
||||
*/
|
||||
static async GetEntireList(family_id: number): Promise<MembersList> {
|
||||
const res = await APIClient.exec({
|
||||
uri: `/family/${family_id}/members`,
|
||||
uri: `/family/${family_id}/genealogy/members`,
|
||||
method: "GET",
|
||||
});
|
||||
|
||||
@ -318,7 +318,7 @@ export class MemberApi {
|
||||
*/
|
||||
static async Update(m: Member): Promise<void> {
|
||||
await APIClient.exec({
|
||||
uri: `/family/${m.family_id}/member/${m.id}`,
|
||||
uri: `/family/${m.family_id}/genealogy/member/${m.id}`,
|
||||
method: "PUT",
|
||||
jsonData: m,
|
||||
});
|
||||
@ -331,7 +331,7 @@ export class MemberApi {
|
||||
const fd = new FormData();
|
||||
fd.append("photo", b);
|
||||
await APIClient.exec({
|
||||
uri: `/family/${m.family_id}/member/${m.id}/photo`,
|
||||
uri: `/family/${m.family_id}/genealogy/member/${m.id}/photo`,
|
||||
method: "PUT",
|
||||
formData: fd,
|
||||
});
|
||||
@ -342,7 +342,7 @@ export class MemberApi {
|
||||
*/
|
||||
static async RemoveMemberPhoto(m: Member): Promise<void> {
|
||||
await APIClient.exec({
|
||||
uri: `/family/${m.family_id}/member/${m.id}/photo`,
|
||||
uri: `/family/${m.family_id}/genealogy/member/${m.id}/photo`,
|
||||
method: "DELETE",
|
||||
});
|
||||
}
|
||||
@ -352,7 +352,7 @@ export class MemberApi {
|
||||
*/
|
||||
static async Delete(m: Member): Promise<void> {
|
||||
await APIClient.exec({
|
||||
uri: `/family/${m.family_id}/member/${m.id}`,
|
||||
uri: `/family/${m.family_id}/genealogy/member/${m.id}`,
|
||||
method: "DELETE",
|
||||
});
|
||||
}
|
@ -0,0 +1,92 @@
|
||||
import {
|
||||
Button,
|
||||
Dialog,
|
||||
DialogActions,
|
||||
DialogContent,
|
||||
DialogTitle,
|
||||
} from "@mui/material";
|
||||
import React from "react";
|
||||
import { ServerApi } from "../../api/ServerApi";
|
||||
import { NewCalendarURL } from "../../api/accommodations/AccommodationsCalendarURLApi";
|
||||
import { checkConstraint } from "../../utils/form_utils";
|
||||
import { useAccommodations } from "../../widgets/accommodations/BaseAccommodationsRoute";
|
||||
import { PropEdit } from "../../widgets/forms/PropEdit";
|
||||
import { PropSelect } from "../../widgets/forms/PropSelect";
|
||||
|
||||
export function CreateAccommodationCalendarURLDialog(p: {
|
||||
open: boolean;
|
||||
onClose: () => void;
|
||||
onSubmitted: (c: NewCalendarURL) => void;
|
||||
}): React.ReactElement {
|
||||
const [calendar, setCalendar] = React.useState<NewCalendarURL>({ name: "" });
|
||||
|
||||
const accommodations = useAccommodations();
|
||||
|
||||
const nameErr = checkConstraint(
|
||||
ServerApi.Config.constraints.accommodation_calendar_name_len,
|
||||
calendar?.name
|
||||
);
|
||||
|
||||
const clearForm = () => {
|
||||
setCalendar({ name: "" });
|
||||
};
|
||||
|
||||
const cancel = () => {
|
||||
clearForm();
|
||||
p.onClose();
|
||||
};
|
||||
|
||||
const submit = async () => {
|
||||
clearForm();
|
||||
p.onSubmitted(calendar!);
|
||||
};
|
||||
|
||||
return (
|
||||
<Dialog open={p.open} onClose={cancel}>
|
||||
<DialogTitle>Création d'un calendrier</DialogTitle>
|
||||
<DialogContent style={{ display: "flex", flexDirection: "column" }}>
|
||||
<PropEdit
|
||||
editable
|
||||
label="Nom"
|
||||
value={calendar?.name}
|
||||
onValueChange={(s) =>
|
||||
setCalendar((a) => {
|
||||
return {
|
||||
...a!,
|
||||
name: s!,
|
||||
};
|
||||
})
|
||||
}
|
||||
size={ServerApi.Config.constraints.accommodation_calendar_name_len}
|
||||
helperText={nameErr}
|
||||
/>
|
||||
|
||||
<PropSelect
|
||||
editing
|
||||
label="Logement ciblé"
|
||||
onValueChange={(v) => {
|
||||
setCalendar((a) => {
|
||||
return {
|
||||
...a!,
|
||||
accommodation_id: v !== "A" && v ? Number(v) : undefined,
|
||||
};
|
||||
});
|
||||
}}
|
||||
options={[
|
||||
{ label: "Tous les logements", value: "A" },
|
||||
...accommodations.accommodations.fullList.map((a) => {
|
||||
return { label: a.name, value: a.id.toString() };
|
||||
}),
|
||||
]}
|
||||
value={calendar.accommodation_id?.toString() ?? "A"}
|
||||
/>
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<Button onClick={cancel}>Annuler</Button>
|
||||
<Button onClick={submit} disabled={!!nameErr}>
|
||||
Créer
|
||||
</Button>
|
||||
</DialogActions>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
@ -0,0 +1,72 @@
|
||||
import ContentCopyIcon from "@mui/icons-material/ContentCopy";
|
||||
import {
|
||||
Button,
|
||||
Dialog,
|
||||
DialogActions,
|
||||
DialogContent,
|
||||
DialogContentText,
|
||||
DialogTitle,
|
||||
FormControl,
|
||||
IconButton,
|
||||
InputAdornment,
|
||||
OutlinedInput,
|
||||
Typography,
|
||||
} from "@mui/material";
|
||||
import QRCode from "react-qr-code";
|
||||
import {
|
||||
AccommodationCalendarURL,
|
||||
AccommodationsCalendarURLApi,
|
||||
} from "../../api/accommodations/AccommodationsCalendarURLApi";
|
||||
import { CopyToClipboard } from "../../widgets/CopyToClipboard";
|
||||
|
||||
export function InstallCalendarDialog(p: {
|
||||
cal?: AccommodationCalendarURL;
|
||||
onClose: () => void;
|
||||
}): React.ReactElement {
|
||||
if (!p.cal) return <></>;
|
||||
|
||||
return (
|
||||
<Dialog open={true} onClose={p.onClose}>
|
||||
<DialogTitle>Installation du calendrier</DialogTitle>
|
||||
<DialogContent>
|
||||
<DialogContentText>
|
||||
<Typography>
|
||||
Afin d'installer le calendrier <i>{p.cal.name}</i> sur votre
|
||||
appareil, veuillez utiliser l'URL suivante :
|
||||
</Typography>
|
||||
<br />
|
||||
<FormControl fullWidth variant="outlined">
|
||||
<OutlinedInput
|
||||
value={AccommodationsCalendarURLApi.CalendarURL(p.cal!)}
|
||||
endAdornment={
|
||||
<InputAdornment position="end">
|
||||
<CopyToClipboard
|
||||
content={AccommodationsCalendarURLApi.CalendarURL(p.cal!)}
|
||||
>
|
||||
<IconButton>
|
||||
<ContentCopyIcon />
|
||||
</IconButton>
|
||||
</CopyToClipboard>
|
||||
</InputAdornment>
|
||||
}
|
||||
/>
|
||||
<div
|
||||
style={{
|
||||
margin: "20px auto",
|
||||
padding: "20px",
|
||||
backgroundColor: "white",
|
||||
}}
|
||||
>
|
||||
<QRCode
|
||||
value={AccommodationsCalendarURLApi.CalendarURL(p.cal!)}
|
||||
/>
|
||||
</div>
|
||||
</FormControl>
|
||||
</DialogContentText>
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<Button onClick={p.onClose}>Fermer</Button>
|
||||
</DialogActions>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
@ -0,0 +1,155 @@
|
||||
import {
|
||||
Button,
|
||||
Dialog,
|
||||
DialogActions,
|
||||
DialogContent,
|
||||
DialogTitle,
|
||||
Tooltip,
|
||||
} from "@mui/material";
|
||||
import React from "react";
|
||||
import { ServerApi } from "../../api/ServerApi";
|
||||
import { UpdateAccommodation } from "../../api/accommodations/AccommodationListApi";
|
||||
import { checkConstraint } from "../../utils/form_utils";
|
||||
import { PropCheckbox } from "../../widgets/forms/PropCheckbox";
|
||||
import { PropEdit } from "../../widgets/forms/PropEdit";
|
||||
import { PropColorPicker } from "../../widgets/forms/PropColorPicker";
|
||||
|
||||
export function UpdateAccommodationDialog(p: {
|
||||
open: boolean;
|
||||
create: boolean;
|
||||
onClose: () => void;
|
||||
onSubmitted: (c: UpdateAccommodation) => void;
|
||||
accommodation: UpdateAccommodation | undefined;
|
||||
}): React.ReactElement {
|
||||
const [accommodation, setAccommodation] = React.useState<
|
||||
UpdateAccommodation | undefined
|
||||
>();
|
||||
|
||||
const nameErr = checkConstraint(
|
||||
ServerApi.Config.constraints.accommodation_name_len,
|
||||
accommodation?.name
|
||||
);
|
||||
const descriptionErr = checkConstraint(
|
||||
ServerApi.Config.constraints.accommodation_description_len,
|
||||
accommodation?.description
|
||||
);
|
||||
|
||||
const clearForm = () => {
|
||||
setAccommodation(undefined);
|
||||
};
|
||||
|
||||
const cancel = () => {
|
||||
clearForm();
|
||||
p.onClose();
|
||||
};
|
||||
|
||||
const submit = async () => {
|
||||
clearForm();
|
||||
p.onSubmitted(accommodation!);
|
||||
};
|
||||
|
||||
React.useEffect(() => {
|
||||
if (!accommodation) setAccommodation(p.accommodation);
|
||||
}, [p.open, p.accommodation]);
|
||||
|
||||
return (
|
||||
<Dialog open={p.open} onClose={cancel}>
|
||||
<DialogTitle>
|
||||
{p.create ? "Création" : "Mise à jour"} d'un logement
|
||||
</DialogTitle>
|
||||
<DialogContent style={{ display: "flex", flexDirection: "column" }}>
|
||||
<PropEdit
|
||||
editable
|
||||
label="Nom"
|
||||
value={accommodation?.name}
|
||||
onValueChange={(s) =>
|
||||
setAccommodation((a) => {
|
||||
return {
|
||||
...a!,
|
||||
name: s!,
|
||||
};
|
||||
})
|
||||
}
|
||||
size={ServerApi.Config.constraints.accommodation_name_len}
|
||||
helperText={nameErr}
|
||||
/>
|
||||
|
||||
<PropEdit
|
||||
editable
|
||||
label="Description"
|
||||
value={accommodation?.description}
|
||||
onValueChange={(s) =>
|
||||
setAccommodation((a) => {
|
||||
return {
|
||||
...a!,
|
||||
description: s!,
|
||||
};
|
||||
})
|
||||
}
|
||||
size={ServerApi.Config.constraints.accommodation_description_len}
|
||||
helperText={descriptionErr}
|
||||
/>
|
||||
|
||||
<PropColorPicker
|
||||
editable
|
||||
label="Couleur"
|
||||
value={accommodation?.color}
|
||||
onChange={(s) =>
|
||||
setAccommodation((a) => {
|
||||
return {
|
||||
...a!,
|
||||
color: s!,
|
||||
};
|
||||
})
|
||||
}
|
||||
/>
|
||||
|
||||
<PropCheckbox
|
||||
editable
|
||||
label="Ouvert aux réservations"
|
||||
checked={accommodation?.open_to_reservations === true}
|
||||
onValueChange={(c) =>
|
||||
setAccommodation((a) => {
|
||||
return {
|
||||
...a!,
|
||||
open_to_reservations: c,
|
||||
};
|
||||
})
|
||||
}
|
||||
/>
|
||||
|
||||
<Tooltip
|
||||
title={
|
||||
"Permet de spécifier si un administrateur de la famille doit valider manuellement les demandes de réservation pour qu'elles soient validées"
|
||||
}
|
||||
>
|
||||
<PropCheckbox
|
||||
checkboxAlwaysVisible
|
||||
editable={accommodation?.open_to_reservations === true}
|
||||
label="Validation des réservations par un administrateur requise"
|
||||
checked={accommodation?.need_validation === true}
|
||||
onValueChange={(c) =>
|
||||
setAccommodation((a) => {
|
||||
return {
|
||||
...a!,
|
||||
need_validation: c,
|
||||
};
|
||||
})
|
||||
}
|
||||
/>
|
||||
</Tooltip>
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<Button onClick={cancel}>Annuler</Button>
|
||||
<Button
|
||||
onClick={submit}
|
||||
disabled={
|
||||
!!nameErr || (!!accommodation?.description && !!descriptionErr)
|
||||
}
|
||||
>
|
||||
{p.create ? "Créer" : "Mettre à jour"}
|
||||
</Button>
|
||||
</DialogActions>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
@ -0,0 +1,192 @@
|
||||
import {
|
||||
Alert,
|
||||
Button,
|
||||
Dialog,
|
||||
DialogActions,
|
||||
DialogContent,
|
||||
DialogTitle,
|
||||
} from "@mui/material";
|
||||
import React from "react";
|
||||
import {
|
||||
AccommodationReservation,
|
||||
AccommodationsReservationsApi,
|
||||
UpdateAccommodationReservation,
|
||||
} from "../../api/accommodations/AccommodationsReservationsApi";
|
||||
import { useAlert } from "../../hooks/context_providers/AlertDialogProvider";
|
||||
import { fmtUnixDate } from "../../utils/time_utils";
|
||||
import { useFamily } from "../../widgets/BaseFamilyRoute";
|
||||
import { useAccommodations } from "../../widgets/accommodations/BaseAccommodationsRoute";
|
||||
import { PropDateInput } from "../../widgets/forms/PropDateInput";
|
||||
import { PropSelect } from "../../widgets/forms/PropSelect";
|
||||
|
||||
export function UpdateReservationDialog(p: {
|
||||
open: boolean;
|
||||
create: boolean;
|
||||
reservation?: UpdateAccommodationReservation;
|
||||
onClose: () => void;
|
||||
onSubmitted: (c: UpdateAccommodationReservation) => void;
|
||||
}): React.ReactElement {
|
||||
const alert = useAlert();
|
||||
|
||||
const family = useFamily();
|
||||
const accommodations = useAccommodations();
|
||||
|
||||
const [reservation, setReservation] = React.useState<
|
||||
UpdateAccommodationReservation | undefined
|
||||
>();
|
||||
|
||||
const [conflicts, setConflicts] = React.useState<
|
||||
AccommodationReservation[] | undefined
|
||||
>(undefined);
|
||||
|
||||
const clearForm = () => {
|
||||
setReservation(undefined);
|
||||
};
|
||||
|
||||
const cancel = () => {
|
||||
clearForm();
|
||||
p.onClose();
|
||||
};
|
||||
|
||||
const submit = async () => {
|
||||
clearForm();
|
||||
p.onSubmitted(reservation!);
|
||||
};
|
||||
|
||||
React.useEffect(() => {
|
||||
if (!reservation) setReservation(p.reservation);
|
||||
}, [p.open, p.reservation]);
|
||||
|
||||
React.useEffect(() => {
|
||||
setConflicts(undefined);
|
||||
(async () => {
|
||||
try {
|
||||
if (
|
||||
!reservation ||
|
||||
reservation.accommodation_id < 1 ||
|
||||
reservation.start < 1 ||
|
||||
reservation.start > reservation.end
|
||||
) {
|
||||
setConflicts([]);
|
||||
return;
|
||||
}
|
||||
|
||||
setConflicts(
|
||||
(
|
||||
await AccommodationsReservationsApi.ReservationsForInterval(
|
||||
family.family,
|
||||
accommodations.accommodations.get(reservation.accommodation_id)!,
|
||||
reservation.start,
|
||||
reservation.end
|
||||
)
|
||||
).filter(
|
||||
(r) =>
|
||||
r.id !== p.reservation?.reservation_id && r.validated !== false
|
||||
)
|
||||
);
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
alert(
|
||||
"Echec de la vérification de la présence de conflits de calendrier !"
|
||||
);
|
||||
}
|
||||
})();
|
||||
}, [
|
||||
p.open,
|
||||
reservation?.accommodation_id,
|
||||
reservation?.start,
|
||||
reservation?.end,
|
||||
]);
|
||||
|
||||
return (
|
||||
<Dialog open={p.open} onClose={cancel}>
|
||||
<DialogTitle>
|
||||
{p.create ? "Création" : "Mise à jour"} d'une réservation
|
||||
</DialogTitle>
|
||||
<DialogContent style={{ display: "flex", flexDirection: "column" }}>
|
||||
<PropSelect
|
||||
editing={p.create}
|
||||
label="Logement ciblé"
|
||||
onValueChange={(v) => {
|
||||
setReservation((a) => {
|
||||
return {
|
||||
...a!,
|
||||
accommodation_id: Number(v),
|
||||
};
|
||||
});
|
||||
}}
|
||||
options={accommodations.accommodations.openToReservationList.map(
|
||||
(a) => {
|
||||
return { label: a.name, value: a.id.toString() };
|
||||
}
|
||||
)}
|
||||
value={
|
||||
reservation?.accommodation_id === -1
|
||||
? ""
|
||||
: reservation?.accommodation_id?.toString()
|
||||
}
|
||||
/>
|
||||
|
||||
<PropDateInput
|
||||
editable
|
||||
label="Date de début"
|
||||
value={reservation?.start}
|
||||
onChange={(s) => {
|
||||
setReservation((r) => {
|
||||
return { ...r!, start: s ?? -1 };
|
||||
});
|
||||
}}
|
||||
minDate={Math.floor(new Date().getTime() / 1000) - 3600 * 24 * 60}
|
||||
canSetMiddleDay
|
||||
/>
|
||||
|
||||
<PropDateInput
|
||||
editable
|
||||
label="Date de fin"
|
||||
value={reservation?.end}
|
||||
lastSecOfDay={true}
|
||||
onChange={(s) => {
|
||||
setReservation((r) => {
|
||||
return { ...r!, end: s ?? -1 };
|
||||
});
|
||||
}}
|
||||
minDate={reservation?.start}
|
||||
canSetMiddleDay
|
||||
/>
|
||||
|
||||
{conflicts && conflicts.length > 0 && (
|
||||
<Alert severity="error">
|
||||
<p>
|
||||
Cette réservation est en conflit avec d'autres réservations sur
|
||||
les intervalles suivants :
|
||||
</p>
|
||||
<ul>
|
||||
{conflicts.map((c, num) => (
|
||||
<li key={num}>
|
||||
Réservation du {fmtUnixDate(c.reservation_start)} au{" "}
|
||||
{fmtUnixDate(c.reservation_end)}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</Alert>
|
||||
)}
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<Button onClick={cancel}>Annuler</Button>
|
||||
<Button
|
||||
onClick={submit}
|
||||
disabled={
|
||||
!(
|
||||
(reservation?.accommodation_id ?? -1) > 0 &&
|
||||
(reservation?.start ?? -1) > 0 &&
|
||||
(reservation?.end ?? -1) > (reservation?.start ?? 0) &&
|
||||
(conflicts?.length ?? 0) === 0
|
||||
)
|
||||
}
|
||||
>
|
||||
{p.create ? "Créer" : "Mettre à jour"}
|
||||
</Button>
|
||||
</DialogActions>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
import { ThemeProvider, createTheme } from "@mui/material/styles";
|
||||
import React from "react";
|
||||
import { PropsWithChildren } from "react";
|
||||
import { frFR as dataGridFr } from "@mui/x-data-grid";
|
||||
import { frFR as dataGridFr } from "@mui/x-data-grid/locales";
|
||||
|
||||
const localStorageKey = "dark-theme";
|
||||
|
||||
|
@ -0,0 +1,52 @@
|
||||
import React, { PropsWithChildren } from "react";
|
||||
import { NewCalendarURL } from "../../../api/accommodations/AccommodationsCalendarURLApi";
|
||||
import { CreateAccommodationCalendarURLDialog } from "../../../dialogs/accommodations/CreateAccommodationCalendarURLDialog";
|
||||
|
||||
type DialogContext = () => Promise<NewCalendarURL | undefined>;
|
||||
|
||||
const DialogContextK = React.createContext<DialogContext | null>(null);
|
||||
|
||||
export function CreateAccommodationCalendarURLDialogProvider(
|
||||
p: PropsWithChildren
|
||||
): React.ReactElement {
|
||||
const [open, setOpen] = React.useState(false);
|
||||
|
||||
const cb = React.useRef<null | ((a: NewCalendarURL | undefined) => void)>(
|
||||
null
|
||||
);
|
||||
|
||||
const handleClose = (res?: NewCalendarURL) => {
|
||||
setOpen(false);
|
||||
|
||||
if (cb.current !== null) cb.current(res);
|
||||
cb.current = null;
|
||||
};
|
||||
|
||||
const hook: DialogContext = () => {
|
||||
setOpen(true);
|
||||
|
||||
return new Promise((res) => {
|
||||
cb.current = res;
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<DialogContextK.Provider value={hook}>
|
||||
{p.children}
|
||||
</DialogContextK.Provider>
|
||||
|
||||
{open && (
|
||||
<CreateAccommodationCalendarURLDialog
|
||||
open={open}
|
||||
onClose={handleClose}
|
||||
onSubmitted={handleClose}
|
||||
/>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
export function useCreateAccommodationCalendarURL(): DialogContext {
|
||||
return React.useContext(DialogContextK)!;
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
import React, { PropsWithChildren } from "react";
|
||||
import { AccommodationCalendarURL } from "../../../api/accommodations/AccommodationsCalendarURLApi";
|
||||
import { InstallCalendarDialog } from "../../../dialogs/accommodations/InstallCalendarDialog";
|
||||
|
||||
type DialogContext = (cal: AccommodationCalendarURL) => Promise<void>;
|
||||
|
||||
const DialogContextK = React.createContext<DialogContext | null>(null);
|
||||
|
||||
export function InstallCalendarDialogProvider(
|
||||
p: PropsWithChildren
|
||||
): React.ReactElement {
|
||||
const [cal, setCal] = React.useState<AccommodationCalendarURL | undefined>();
|
||||
|
||||
const cb = React.useRef<null | (() => void)>(null);
|
||||
|
||||
const handleClose = () => {
|
||||
setCal(undefined);
|
||||
|
||||
if (cb.current !== null) cb.current();
|
||||
cb.current = null;
|
||||
};
|
||||
|
||||
const hook: DialogContext = (c) => {
|
||||
setCal(c);
|
||||
|
||||
return new Promise((res) => {
|
||||
cb.current = res;
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<DialogContextK.Provider value={hook}>
|
||||
{p.children}
|
||||
</DialogContextK.Provider>
|
||||
|
||||
{cal && <InstallCalendarDialog cal={cal} onClose={handleClose} />}
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
export function useInstallCalendarDialog(): DialogContext {
|
||||
return React.useContext(DialogContextK)!;
|
||||
}
|
@ -0,0 +1,64 @@
|
||||
import React, { PropsWithChildren } from "react";
|
||||
import { UpdateAccommodation } from "../../../api/accommodations/AccommodationListApi";
|
||||
import { UpdateAccommodationDialog } from "../../../dialogs/accommodations/UpdateAccommodationDialog";
|
||||
|
||||
type DialogContext = (
|
||||
accommodation: UpdateAccommodation,
|
||||
create: boolean
|
||||
) => Promise<UpdateAccommodation | undefined>;
|
||||
|
||||
const DialogContextK = React.createContext<DialogContext | null>(null);
|
||||
|
||||
export function UpdateAccommodationDialogProvider(
|
||||
p: PropsWithChildren
|
||||
): React.ReactElement {
|
||||
const [open, setOpen] = React.useState(false);
|
||||
|
||||
const [accommodation, setAccommodation] = React.useState<
|
||||
UpdateAccommodation | undefined
|
||||
>(undefined);
|
||||
const [create, setCreate] = React.useState(false);
|
||||
|
||||
const cb = React.useRef<
|
||||
null | ((a: UpdateAccommodation | undefined) => void)
|
||||
>(null);
|
||||
|
||||
const handleClose = (res?: UpdateAccommodation) => {
|
||||
setOpen(false);
|
||||
|
||||
if (cb.current !== null) cb.current(res);
|
||||
cb.current = null;
|
||||
};
|
||||
|
||||
const hook: DialogContext = (accommodation, create) => {
|
||||
setAccommodation(accommodation);
|
||||
setCreate(create);
|
||||
setOpen(true);
|
||||
|
||||
return new Promise((res) => {
|
||||
cb.current = res;
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<DialogContextK.Provider value={hook}>
|
||||
{p.children}
|
||||
</DialogContextK.Provider>
|
||||
|
||||
{open && (
|
||||
<UpdateAccommodationDialog
|
||||
open={open}
|
||||
accommodation={accommodation}
|
||||
create={create}
|
||||
onClose={handleClose}
|
||||
onSubmitted={handleClose}
|
||||
/>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
export function useUpdateAccommodation(): DialogContext {
|
||||
return React.useContext(DialogContextK)!;
|
||||
}
|
@ -0,0 +1,64 @@
|
||||
import React, { PropsWithChildren } from "react";
|
||||
import { UpdateAccommodationReservation } from "../../../api/accommodations/AccommodationsReservationsApi";
|
||||
import { UpdateReservationDialog } from "../../../dialogs/accommodations/UpdateReservationDialog";
|
||||
|
||||
type DialogContext = (
|
||||
reservation: UpdateAccommodationReservation,
|
||||
create: boolean
|
||||
) => Promise<UpdateAccommodationReservation | undefined>;
|
||||
|
||||
const DialogContextK = React.createContext<DialogContext | null>(null);
|
||||
|
||||
export function UpdateReservationDialogProvider(
|
||||
p: PropsWithChildren
|
||||
): React.ReactElement {
|
||||
const [open, setOpen] = React.useState(false);
|
||||
|
||||
const [reservation, setReservation] = React.useState<
|
||||
UpdateAccommodationReservation | undefined
|
||||
>(undefined);
|
||||
const [create, setCreate] = React.useState(false);
|
||||
|
||||
const cb = React.useRef<
|
||||
null | ((a: UpdateAccommodationReservation | undefined) => void)
|
||||
>(null);
|
||||
|
||||
const handleClose = (res?: UpdateAccommodationReservation) => {
|
||||
setOpen(false);
|
||||
|
||||
if (cb.current !== null) cb.current(res);
|
||||
cb.current = null;
|
||||
};
|
||||
|
||||
const hook: DialogContext = (accommodation, create) => {
|
||||
setReservation(accommodation);
|
||||
setCreate(create);
|
||||
setOpen(true);
|
||||
|
||||
return new Promise((res) => {
|
||||
cb.current = res;
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<DialogContextK.Provider value={hook}>
|
||||
{p.children}
|
||||
</DialogContextK.Provider>
|
||||
|
||||
{open && (
|
||||
<UpdateReservationDialog
|
||||
open={open}
|
||||
reservation={reservation}
|
||||
create={create}
|
||||
onClose={handleClose}
|
||||
onSubmitted={handleClose}
|
||||
/>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
export function useUpdateAccommodationReservation(): DialogContext {
|
||||
return React.useContext(DialogContextK)!;
|
||||
}
|
@ -3,7 +3,6 @@ import ReactDOM from "react-dom/client";
|
||||
import { App } from "./App";
|
||||
import { ServerApi } from "./api/ServerApi";
|
||||
import "./index.css";
|
||||
import reportWebVitals from "./reportWebVitals";
|
||||
|
||||
// Roboto font
|
||||
import "@fontsource/roboto/300.css";
|
||||
@ -61,8 +60,3 @@ async function init() {
|
||||
}
|
||||
|
||||
init();
|
||||
|
||||
// If you want to start measuring performance in your app, pass a function
|
||||
// to log results (for example: reportWebVitals(console.log))
|
||||
// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
|
||||
reportWebVitals();
|
||||
|
1
geneit_app/src/react-app-env.d.ts
vendored
1
geneit_app/src/react-app-env.d.ts
vendored
@ -1 +0,0 @@
|
||||
/// <reference types="react-scripts" />
|
@ -1,15 +0,0 @@
|
||||
import { ReportHandler } from 'web-vitals';
|
||||
|
||||
const reportWebVitals = (onPerfEntry?: ReportHandler) => {
|
||||
if (onPerfEntry && onPerfEntry instanceof Function) {
|
||||
import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => {
|
||||
getCLS(onPerfEntry);
|
||||
getFID(onPerfEntry);
|
||||
getFCP(onPerfEntry);
|
||||
getLCP(onPerfEntry);
|
||||
getTTFB(onPerfEntry);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
export default reportWebVitals;
|
@ -1,4 +1,5 @@
|
||||
import { Visibility, VisibilityOff } from "@mui/icons-material";
|
||||
import VisibilityIcon from "@mui/icons-material/Visibility";
|
||||
import VisibilityOffIcon from "@mui/icons-material/VisibilityOff";
|
||||
import {
|
||||
Alert,
|
||||
CircularProgress,
|
||||
@ -148,7 +149,7 @@ export function LoginRoute(): React.ReactElement {
|
||||
onMouseDown={handleMouseDownPassword}
|
||||
edge="end"
|
||||
>
|
||||
{showPassword ? <VisibilityOff /> : <Visibility />}
|
||||
{showPassword ? <VisibilityOffIcon /> : <VisibilityIcon />}
|
||||
</IconButton>
|
||||
</Tooltip>
|
||||
</InputAdornment>
|
||||
@ -167,7 +168,7 @@ export function LoginRoute(): React.ReactElement {
|
||||
</Button>
|
||||
|
||||
<Grid container>
|
||||
<Grid item xs>
|
||||
<Grid size={"grow"}>
|
||||
<Typography variant="body2" color={"primary"}>
|
||||
<Link
|
||||
to="/password_forgotten"
|
||||
@ -177,7 +178,7 @@ export function LoginRoute(): React.ReactElement {
|
||||
</Link>
|
||||
</Typography>
|
||||
</Grid>
|
||||
<Grid item>
|
||||
<Grid>
|
||||
<Typography variant="body2" color={"primary"}>
|
||||
<Link
|
||||
to="/new-account"
|
||||
|
@ -1,24 +0,0 @@
|
||||
import { useFamily } from "../../widgets/BaseFamilyRoute";
|
||||
import { FamilyPageTitle } from "../../widgets/FamilyPageTitle";
|
||||
|
||||
export function FamilyHomeRoute(): React.ReactElement {
|
||||
const family = useFamily();
|
||||
return (
|
||||
<>
|
||||
<FamilyPageTitle title="Votre famille" />
|
||||
<div style={{ margin: "20px" }}>
|
||||
<p>
|
||||
Bienvenue sur l'espace dédié à la généalogie de votre famille !
|
||||
Veuillez utiliser le menu situé à gauche pour accéder aux différentes
|
||||
sections de l'application.
|
||||
</p>
|
||||
<p>Nombre de fiches de membres: {family.members.size}</p>
|
||||
<p>Nombre de fiches de couples: {family.couples.size}</p>
|
||||
<p>
|
||||
Vous pouvez inviter d'autres personnes à rejoindre cette famille en
|
||||
leur donnant une copie du code d'invitation
|
||||
</p>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
@ -1,26 +1,19 @@
|
||||
import DownloadIcon from "@mui/icons-material/Download";
|
||||
import UploadIcon from "@mui/icons-material/Upload";
|
||||
import {
|
||||
Alert,
|
||||
Box,
|
||||
Button,
|
||||
CardActions,
|
||||
CardContent,
|
||||
Checkbox,
|
||||
FormControlLabel,
|
||||
Switch,
|
||||
TextField,
|
||||
Tooltip,
|
||||
Typography,
|
||||
} from "@mui/material";
|
||||
import React from "react";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { DataApi } from "../../api/DataApi";
|
||||
import { FamilyApi } from "../../api/FamilyApi";
|
||||
import { ServerApi } from "../../api/ServerApi";
|
||||
import { useAlert } from "../../hooks/context_providers/AlertDialogProvider";
|
||||
import { useConfirm } from "../../hooks/context_providers/ConfirmDialogProvider";
|
||||
import { useLoadingMessage } from "../../hooks/context_providers/LoadingMessageProvider";
|
||||
import { downloadBlob, selectFileToUpload } from "../../utils/files_utils";
|
||||
import { useFamily } from "../../widgets/BaseFamilyRoute";
|
||||
import { FamilyCard } from "../../widgets/FamilyCard";
|
||||
import { formatDate } from "../../widgets/TimeWidget";
|
||||
@ -55,7 +48,6 @@ export function FamilySettingsRoute(): React.ReactElement {
|
||||
return (
|
||||
<>
|
||||
<FamilySettingsCard />
|
||||
<FamilyExportCard />
|
||||
<div style={{ textAlign: "center", marginTop: "50px" }}>
|
||||
<Button
|
||||
size="small"
|
||||
@ -76,8 +68,11 @@ function FamilySettingsCard(): React.ReactElement {
|
||||
const family = useFamily();
|
||||
|
||||
const [newName, setNewName] = React.useState(family.family.name);
|
||||
const [disableCouplePhotos, setDisableCouplePhotos] = React.useState(
|
||||
family.family.disable_couple_photos
|
||||
const [enableGenealogy, setEnableGenealogy] = React.useState(
|
||||
family.family.enable_genealogy
|
||||
);
|
||||
const [enableAccommodations, setEnableAccommodations] = React.useState(
|
||||
family.family.enable_accommodations
|
||||
);
|
||||
|
||||
const canEdit = family.family.is_admin;
|
||||
@ -93,7 +88,8 @@ function FamilySettingsCard(): React.ReactElement {
|
||||
await FamilyApi.UpdateFamily({
|
||||
id: family.family.family_id,
|
||||
name: newName,
|
||||
disable_couple_photos: disableCouplePhotos,
|
||||
enable_genealogy: enableGenealogy,
|
||||
enable_accommodations: enableAccommodations,
|
||||
});
|
||||
|
||||
family.reloadFamilyInfo();
|
||||
@ -126,14 +122,12 @@ function FamilySettingsCard(): React.ReactElement {
|
||||
label="Identifiant"
|
||||
value={family.family.family_id}
|
||||
/>
|
||||
|
||||
<TextField
|
||||
disabled
|
||||
fullWidth
|
||||
label="Création de la famille"
|
||||
value={formatDate(family.family.time_create)}
|
||||
/>
|
||||
|
||||
<TextField
|
||||
fullWidth
|
||||
label="Nom de la famille"
|
||||
@ -144,18 +138,26 @@ function FamilySettingsCard(): React.ReactElement {
|
||||
maxLength: ServerApi.Config.constraints.family_name_len.max,
|
||||
}}
|
||||
/>
|
||||
<Tooltip title="Les photos de couple ne sont pas utilisées en pratique dans les arbres généalogiques. Il est possible de masquer les formulaires d'édition de photos de couple pour limiter le risque de confusion.">
|
||||
<FormControlLabel
|
||||
disabled={!canEdit}
|
||||
control={
|
||||
<Checkbox
|
||||
checked={disableCouplePhotos}
|
||||
onChange={(_e, c) => setDisableCouplePhotos(c)}
|
||||
/>
|
||||
}
|
||||
label="Désactiver les photos de couple"
|
||||
/>
|
||||
</Tooltip>
|
||||
<FormControlLabel
|
||||
disabled={!canEdit}
|
||||
control={
|
||||
<Switch
|
||||
checked={enableGenealogy}
|
||||
onChange={(_e, c) => setEnableGenealogy(c)}
|
||||
/>
|
||||
}
|
||||
label="Activer le module de généalogie"
|
||||
/>
|
||||
<FormControlLabel
|
||||
disabled={!canEdit}
|
||||
control={
|
||||
<Switch
|
||||
checked={enableAccommodations}
|
||||
onChange={(_e, c) => setEnableAccommodations(c)}
|
||||
/>
|
||||
}
|
||||
label="Activer le module de réservation de logements"
|
||||
/>
|
||||
</Box>
|
||||
</CardContent>
|
||||
<CardActions>
|
||||
@ -170,109 +172,3 @@ function FamilySettingsCard(): React.ReactElement {
|
||||
</FamilyCard>
|
||||
);
|
||||
}
|
||||
|
||||
function FamilyExportCard(): React.ReactElement {
|
||||
const loading = useLoadingMessage();
|
||||
const confirm = useConfirm();
|
||||
const alert = useAlert();
|
||||
|
||||
const family = useFamily();
|
||||
|
||||
const [error, setError] = React.useState<string>();
|
||||
const [success, setSuccess] = React.useState<string>();
|
||||
|
||||
const exportData = async () => {
|
||||
loading.show("Export des données");
|
||||
try {
|
||||
setError(undefined);
|
||||
setSuccess(undefined);
|
||||
|
||||
const blob = await DataApi.ExportData(family.familyId);
|
||||
downloadBlob(blob, `Export-${new Date().getTime()}.zip`);
|
||||
|
||||
setSuccess("Export des données effectué avec succès !");
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
setError("Echec de l'export des données de la famille !");
|
||||
}
|
||||
loading.hide();
|
||||
};
|
||||
|
||||
const importData = async () => {
|
||||
try {
|
||||
if (
|
||||
!(await confirm(
|
||||
"Attention ! Cette opération a pour effet d'effacer toutes les données existantes en base ! Voulez-vous vraiment poursuivre l'opération ?"
|
||||
))
|
||||
)
|
||||
return;
|
||||
|
||||
const file = await selectFileToUpload({
|
||||
allowedTypes: ["application/zip"],
|
||||
});
|
||||
if (file === null) return;
|
||||
|
||||
setError(undefined);
|
||||
setSuccess(undefined);
|
||||
|
||||
loading.show("Restauration des données de la famille en cours...");
|
||||
|
||||
await DataApi.ImportData(family.familyId, file);
|
||||
|
||||
family.reloadFamilyInfo();
|
||||
|
||||
alert("Import des données de la famille effectué avec succès !");
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
setError(`Echec de l'import des données de la famille ! (${e})`);
|
||||
}
|
||||
|
||||
loading.hide();
|
||||
};
|
||||
|
||||
return (
|
||||
<FamilyCard error={error} success={success}>
|
||||
<CardContent>
|
||||
<Typography gutterBottom variant="h5" component="div">
|
||||
Export / import des données de la famille
|
||||
</Typography>
|
||||
<p>
|
||||
Vous pouvez, à des fins de sauvegardes ou de transfert, exporter et
|
||||
importer l'ensemble des données des membres et des couples de cette
|
||||
famille, sous format ZIP.
|
||||
</p>
|
||||
|
||||
<Alert severity="warning">
|
||||
Attention ! La restauration des données de la famille provoque
|
||||
préalablement l'effacement de toutes les données enregistrées dans la
|
||||
famille ! Par ailleurs, la restauration n'est pas réversible !
|
||||
</Alert>
|
||||
|
||||
<p> </p>
|
||||
|
||||
<Button
|
||||
startIcon={<DownloadIcon />}
|
||||
variant="outlined"
|
||||
fullWidth
|
||||
onClick={exportData}
|
||||
size={"large"}
|
||||
style={{ marginBottom: "10px" }}
|
||||
>
|
||||
Exporter les données de la famille
|
||||
</Button>
|
||||
|
||||
<Button
|
||||
startIcon={<UploadIcon />}
|
||||
variant="outlined"
|
||||
color="warning"
|
||||
fullWidth
|
||||
onClick={importData}
|
||||
disabled={!family.family.is_admin}
|
||||
size={"large"}
|
||||
>
|
||||
Importer les données de la famille
|
||||
</Button>
|
||||
</CardContent>
|
||||
</FamilyCard>
|
||||
);
|
||||
}
|
||||
|
@ -0,0 +1,21 @@
|
||||
import { FamilyPageTitle } from "../../../widgets/FamilyPageTitle";
|
||||
import { useAccommodations } from "../../../widgets/accommodations/BaseAccommodationsRoute";
|
||||
|
||||
export function AccommodationsHomeRoute(): React.ReactElement {
|
||||
const accommodations = useAccommodations();
|
||||
return (
|
||||
<>
|
||||
<FamilyPageTitle title="Réservation de logements" />
|
||||
<div style={{ margin: "20px" }}>
|
||||
<p>
|
||||
Depuis cette section de l'application, vous pouvez effectuer des
|
||||
réservations de logements.
|
||||
</p>
|
||||
<p> </p>
|
||||
<p>
|
||||
Nombre de logements définis : {accommodations.accommodations.size}
|
||||
</p>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
@ -0,0 +1,598 @@
|
||||
import { DateSelectArg, EventClickArg } from "@fullcalendar/core";
|
||||
import frLocale from "@fullcalendar/core/locales/fr";
|
||||
import dayGridPlugin from "@fullcalendar/daygrid";
|
||||
import interactionPlugin from "@fullcalendar/interaction";
|
||||
import listPlugin from "@fullcalendar/list";
|
||||
import FullCalendar from "@fullcalendar/react";
|
||||
import DeleteIcon from "@mui/icons-material/Delete";
|
||||
import EditIcon from "@mui/icons-material/Edit";
|
||||
import RuleIcon from "@mui/icons-material/Rule";
|
||||
import {
|
||||
Alert,
|
||||
Avatar,
|
||||
Card,
|
||||
CardActions,
|
||||
CardContent,
|
||||
CardHeader,
|
||||
Checkbox,
|
||||
FormControl,
|
||||
FormControlLabel,
|
||||
FormGroup,
|
||||
FormLabel,
|
||||
IconButton,
|
||||
Menu,
|
||||
MenuItem,
|
||||
Popover,
|
||||
Tooltip,
|
||||
Typography,
|
||||
} from "@mui/material";
|
||||
import { red } from "@mui/material/colors";
|
||||
import React from "react";
|
||||
import { FamilyApi, FamilyUser } from "../../../api/FamilyApi";
|
||||
import { Accommodation } from "../../../api/accommodations/AccommodationListApi";
|
||||
import {
|
||||
AccommodationReservation,
|
||||
AccommodationsReservationsApi,
|
||||
AccommodationsReservationsList,
|
||||
ValidateResaResult,
|
||||
} from "../../../api/accommodations/AccommodationsReservationsApi";
|
||||
import { useAlert } from "../../../hooks/context_providers/AlertDialogProvider";
|
||||
import { useConfirm } from "../../../hooks/context_providers/ConfirmDialogProvider";
|
||||
import { useLoadingMessage } from "../../../hooks/context_providers/LoadingMessageProvider";
|
||||
import { useSnackbar } from "../../../hooks/context_providers/SnackbarProvider";
|
||||
import { useUpdateAccommodationReservation } from "../../../hooks/context_providers/accommodations/UpdateReservationDialogProvider";
|
||||
import {
|
||||
fmtUnixDate,
|
||||
fmtUnixDateFullCalendar,
|
||||
} from "../../../utils/time_utils";
|
||||
import { AsyncWidget } from "../../../widgets/AsyncWidget";
|
||||
import { useUser } from "../../../widgets/BaseAuthenticatedPage";
|
||||
import { useFamily } from "../../../widgets/BaseFamilyRoute";
|
||||
import { FamilyPageTitle } from "../../../widgets/FamilyPageTitle";
|
||||
import { useAccommodations } from "../../../widgets/accommodations/BaseAccommodationsRoute";
|
||||
|
||||
export function AccommodationsReservationsRoute(): React.ReactElement {
|
||||
const snackbar = useSnackbar();
|
||||
const alert = useAlert();
|
||||
const confirm = useConfirm();
|
||||
const loadingMessage = useLoadingMessage();
|
||||
|
||||
const loadKey = React.useRef(1);
|
||||
|
||||
const user = useUser();
|
||||
const family = useFamily();
|
||||
const accommodations = useAccommodations();
|
||||
const updateReservation = useUpdateAccommodationReservation();
|
||||
|
||||
const [reservations, setReservations] = React.useState<
|
||||
AccommodationsReservationsList | undefined
|
||||
>();
|
||||
const [users, setUsers] = React.useState<FamilyUser[] | null>(null);
|
||||
|
||||
const [showValidated, setShowValidated] = React.useState(true);
|
||||
const [showRejected, setShowRejected] = React.useState(true);
|
||||
const [showPending, setShowPending] = React.useState(true);
|
||||
|
||||
const [hiddenPeople, setHiddenPeople] = React.useState<Set<number>>(
|
||||
new Set()
|
||||
);
|
||||
const [hiddenAccommodations, setHiddenAccommodations] = React.useState<
|
||||
Set<number>
|
||||
>(new Set());
|
||||
|
||||
const eventPopupAnchor = React.useRef<HTMLDivElement>(null);
|
||||
const [activeEvent, setActiveEvent] = React.useState<
|
||||
| undefined
|
||||
| {
|
||||
user: FamilyUser;
|
||||
accommodation: Accommodation;
|
||||
reservation: AccommodationReservation;
|
||||
|
||||
x: number;
|
||||
y: number;
|
||||
w: number;
|
||||
h: number;
|
||||
}
|
||||
>();
|
||||
|
||||
const [validateResaAnchorEl, setValidateResaAnchorEl] =
|
||||
React.useState<null | HTMLElement>(null);
|
||||
|
||||
const load = async () => {
|
||||
setReservations(
|
||||
await AccommodationsReservationsApi.FullListOfFamily(family.family)
|
||||
);
|
||||
setUsers(await FamilyApi.GetUsersList(family.family.family_id));
|
||||
};
|
||||
|
||||
const reload = async () => {
|
||||
loadKey.current += 1;
|
||||
setUsers(null);
|
||||
};
|
||||
|
||||
const visibleReservations = React.useMemo(() => {
|
||||
return reservations?.filter((r) => {
|
||||
if (!showValidated && r.validated === true) return false;
|
||||
if (!showPending && r.validated === null) return false;
|
||||
if (!showRejected && r.validated === false) return false;
|
||||
if (hiddenPeople.has(r.user_id)) return false;
|
||||
if (hiddenAccommodations.has(r.accommodation_id)) return false;
|
||||
return true;
|
||||
});
|
||||
}, [
|
||||
showValidated,
|
||||
showRejected,
|
||||
showPending,
|
||||
hiddenPeople,
|
||||
hiddenAccommodations,
|
||||
reservations,
|
||||
]);
|
||||
|
||||
const onSelect = async (d: DateSelectArg) => {
|
||||
try {
|
||||
const resa = await updateReservation(
|
||||
{
|
||||
accommodation_id: -1,
|
||||
start: Math.floor(d.start.getTime() / 1000),
|
||||
end: Math.floor(d.end.getTime() / 1000),
|
||||
},
|
||||
true
|
||||
);
|
||||
|
||||
if (!resa) return;
|
||||
|
||||
loadingMessage.show("Création de la réservation en cours...");
|
||||
|
||||
await AccommodationsReservationsApi.Create(family.family, resa);
|
||||
|
||||
reload();
|
||||
snackbar("La réservation a été créée avec succès !");
|
||||
} catch (e) {
|
||||
console.error("Failed to create a reservation!", e);
|
||||
alert("Échec de la création de la réservation!");
|
||||
} finally {
|
||||
loadingMessage.hide();
|
||||
}
|
||||
};
|
||||
|
||||
const onEventClick = (ev: EventClickArg) => {
|
||||
const id: number = ev.event.extendedProps.id;
|
||||
const resa = reservations?.get(id)!;
|
||||
const acc = accommodations.accommodations.get(resa.accommodation_id)!;
|
||||
|
||||
const user = users?.find((u) => u.user_id === resa.user_id);
|
||||
|
||||
if (!user) {
|
||||
console.error(`User ${resa.user_id} not found!`);
|
||||
return;
|
||||
}
|
||||
|
||||
const loc = ev.el.getBoundingClientRect();
|
||||
setActiveEvent({
|
||||
reservation: resa,
|
||||
accommodation: acc,
|
||||
user: user,
|
||||
|
||||
x: loc.left,
|
||||
y: loc.top,
|
||||
w: loc.width,
|
||||
h: loc.height,
|
||||
});
|
||||
};
|
||||
|
||||
const respondToResaRequest = async (
|
||||
r: AccommodationReservation,
|
||||
validate: boolean
|
||||
) => {
|
||||
try {
|
||||
loadingMessage.show("Validation de la réservation en cours...");
|
||||
|
||||
setValidateResaAnchorEl(null);
|
||||
setActiveEvent(undefined);
|
||||
|
||||
const res = await AccommodationsReservationsApi.Validate(r, validate);
|
||||
|
||||
if (res === ValidateResaResult.Conflict) {
|
||||
throw new Error(
|
||||
"The reservation is in conflict with other reservations!"
|
||||
);
|
||||
} else if (res === ValidateResaResult.Error) {
|
||||
throw new Error("Failed to validate the reservation!");
|
||||
}
|
||||
|
||||
reload();
|
||||
snackbar("La réservation a été mise à jour avec succès !");
|
||||
} catch (e) {
|
||||
console.error("Failed to respond to reservation request!", e);
|
||||
alert(`Echec de l'enregistrement de la réponse à la réservation ! ${e}`);
|
||||
} finally {
|
||||
loadingMessage.hide();
|
||||
}
|
||||
};
|
||||
|
||||
const validateReservation = async (r: AccommodationReservation) => {
|
||||
respondToResaRequest(r, true);
|
||||
};
|
||||
|
||||
const rejectReservation = async (r: AccommodationReservation) => {
|
||||
if (
|
||||
!(await confirm(
|
||||
"Voulez-vous vraiment rejeter cette demande de réservation ?"
|
||||
))
|
||||
)
|
||||
return;
|
||||
respondToResaRequest(r, false);
|
||||
};
|
||||
|
||||
const changeReservation = async (r: AccommodationReservation) => {
|
||||
try {
|
||||
const ac = accommodations.accommodations.get(r.accommodation_id);
|
||||
if (
|
||||
ac?.need_validation &&
|
||||
!(await confirm(
|
||||
"Voulez-vous vraiment changer cette réservation ? Celle-ci devra être de nouveau validée !"
|
||||
))
|
||||
)
|
||||
return;
|
||||
|
||||
const newResa = await updateReservation(
|
||||
{
|
||||
reservation_id: r.id,
|
||||
accommodation_id: r.accommodation_id,
|
||||
start: r.reservation_start,
|
||||
end: r.reservation_end,
|
||||
},
|
||||
false
|
||||
);
|
||||
|
||||
if (!newResa) return;
|
||||
|
||||
setActiveEvent(undefined);
|
||||
loadingMessage.show("Mise à jour de la réservation en cours...");
|
||||
|
||||
await AccommodationsReservationsApi.Update(family.family, newResa);
|
||||
|
||||
reload();
|
||||
snackbar("La réservation a été mise à jour avec succès !");
|
||||
} catch (e) {
|
||||
console.error("Failed to update a reservation!", e);
|
||||
alert("Échec de la mise à jour de la réservation!");
|
||||
} finally {
|
||||
loadingMessage.hide();
|
||||
}
|
||||
};
|
||||
|
||||
const deleteReservation = async (r: AccommodationReservation) => {
|
||||
try {
|
||||
if (
|
||||
!(await confirm(
|
||||
"Voulez-vous vraiment supprimer cette réservation ? L'opération n'est pas réversible !"
|
||||
))
|
||||
)
|
||||
return;
|
||||
|
||||
setActiveEvent(undefined);
|
||||
loadingMessage.show("Suppression de la réservation en cours...");
|
||||
|
||||
await AccommodationsReservationsApi.Delete(r);
|
||||
|
||||
reload();
|
||||
snackbar("La réservation a été supprimée avec succès !");
|
||||
} catch (e) {
|
||||
console.error("Failed to delete a reservation!", e);
|
||||
alert("Échec de la suppression de la réservation!");
|
||||
} finally {
|
||||
loadingMessage.hide();
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<FamilyPageTitle title="Réservations" />
|
||||
<AsyncWidget
|
||||
loadKey={loadKey.current}
|
||||
load={load}
|
||||
errMsg="Echec du chargement de la liste des réservations !"
|
||||
build={() => (
|
||||
<div style={{ display: "flex", flexDirection: "row" }}>
|
||||
<div style={{ flex: 1, maxWidth: "250px", marginRight: "20px" }}>
|
||||
<Alert severity="info">
|
||||
Cliquez sur le calendrier pour créer une réservation.
|
||||
</Alert>
|
||||
|
||||
{/* Invitation status */}
|
||||
<FormControl
|
||||
sx={{ m: 3 }}
|
||||
component="fieldset"
|
||||
variant="standard"
|
||||
>
|
||||
<FormLabel component="legend">Status</FormLabel>
|
||||
<FormGroup>
|
||||
<FormControlLabel
|
||||
control={
|
||||
<Checkbox
|
||||
checked={showValidated}
|
||||
onChange={(_ev, v) => setShowValidated(v)}
|
||||
color="success"
|
||||
/>
|
||||
}
|
||||
label="Validées"
|
||||
/>
|
||||
<FormControlLabel
|
||||
control={
|
||||
<Checkbox
|
||||
checked={showRejected}
|
||||
onChange={(_ev, v) => setShowRejected(v)}
|
||||
color="error"
|
||||
/>
|
||||
}
|
||||
label="Rejetées"
|
||||
/>
|
||||
<FormControlLabel
|
||||
control={
|
||||
<Checkbox
|
||||
checked={showPending}
|
||||
onChange={(_ev, v) => setShowPending(v)}
|
||||
color="info"
|
||||
/>
|
||||
}
|
||||
label="En attente de validation"
|
||||
/>
|
||||
</FormGroup>
|
||||
</FormControl>
|
||||
|
||||
{/* Accommodations */}
|
||||
<FormControl
|
||||
sx={{ m: 3 }}
|
||||
component="fieldset"
|
||||
variant="standard"
|
||||
>
|
||||
<FormLabel component="legend">Logements</FormLabel>
|
||||
<FormGroup>
|
||||
{accommodations.accommodations.fullList.map((a) => (
|
||||
<FormControlLabel
|
||||
key={a.id}
|
||||
control={
|
||||
<Checkbox
|
||||
sx={{
|
||||
color: "#" + a.color,
|
||||
"&.Mui-checked": {
|
||||
color: "#" + a.color,
|
||||
},
|
||||
}}
|
||||
checked={!hiddenAccommodations.has(a.id)}
|
||||
onChange={(_ev, v) => {
|
||||
if (v) hiddenAccommodations.delete(a.id);
|
||||
else hiddenAccommodations.add(a.id);
|
||||
setHiddenAccommodations(
|
||||
new Set(hiddenAccommodations)
|
||||
);
|
||||
}}
|
||||
/>
|
||||
}
|
||||
label={a.name}
|
||||
/>
|
||||
))}
|
||||
</FormGroup>
|
||||
</FormControl>
|
||||
|
||||
{/* People */}
|
||||
<FormControl
|
||||
sx={{ m: 3 }}
|
||||
component="fieldset"
|
||||
variant="standard"
|
||||
>
|
||||
<FormLabel component="legend">Personnes</FormLabel>
|
||||
<FormGroup>
|
||||
{users?.map((u) => (
|
||||
<FormControlLabel
|
||||
key={u.user_id}
|
||||
control={
|
||||
<Checkbox
|
||||
checked={!hiddenPeople.has(u.user_id)}
|
||||
onChange={(_ev, v) => {
|
||||
if (v) hiddenPeople.delete(u.user_id);
|
||||
else hiddenPeople.add(u.user_id);
|
||||
setHiddenPeople(new Set(hiddenPeople));
|
||||
}}
|
||||
/>
|
||||
}
|
||||
label={u.user_name}
|
||||
/>
|
||||
))}
|
||||
</FormGroup>
|
||||
</FormControl>
|
||||
</div>
|
||||
|
||||
{/* The calendar */}
|
||||
<div style={{ flex: 5 }}>
|
||||
<FullCalendar
|
||||
editable={true}
|
||||
selectable={true}
|
||||
plugins={[dayGridPlugin, listPlugin, interactionPlugin]}
|
||||
initialView="dayGridMonth"
|
||||
height="700px"
|
||||
locale={frLocale}
|
||||
headerToolbar={{
|
||||
left: "prev,next today",
|
||||
center: "title",
|
||||
right: "dayGridMonth,dayGridWeek,dayGridDay,listWeek",
|
||||
}}
|
||||
select={onSelect}
|
||||
eventClick={onEventClick}
|
||||
events={visibleReservations?.map((r) => {
|
||||
const a = accommodations.accommodations.get(
|
||||
r.accommodation_id
|
||||
)!;
|
||||
const u = users?.find((u) => u.user_id === r.user_id);
|
||||
return {
|
||||
title: `${u?.user_name} - ${a.name}`,
|
||||
start: fmtUnixDateFullCalendar(r.reservation_start, false),
|
||||
end: fmtUnixDateFullCalendar(r.reservation_end, true),
|
||||
allDay: true,
|
||||
color: a.color ? "#" + a.color : undefined,
|
||||
borderColor:
|
||||
r.validated === true
|
||||
? "green"
|
||||
: r.validated === false
|
||||
? "red"
|
||||
: "grey ",
|
||||
extendedProps: {
|
||||
id: r.id,
|
||||
},
|
||||
};
|
||||
})}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* Calendar event popover */}
|
||||
<div
|
||||
ref={eventPopupAnchor}
|
||||
id="active-event-anchor"
|
||||
style={{
|
||||
position: "fixed",
|
||||
top: activeEvent?.y + "px",
|
||||
left: activeEvent?.x + "px",
|
||||
width: activeEvent?.w + "px",
|
||||
height: activeEvent?.h + "px",
|
||||
backgroundColor: "pink",
|
||||
zIndex: 0,
|
||||
}}
|
||||
></div>
|
||||
<Popover
|
||||
open={activeEvent !== undefined}
|
||||
anchorEl={eventPopupAnchor.current}
|
||||
onClose={() => {
|
||||
setActiveEvent(undefined);
|
||||
}}
|
||||
anchorOrigin={{
|
||||
vertical: "bottom",
|
||||
horizontal: "left",
|
||||
}}
|
||||
>
|
||||
<Card sx={{ maxWidth: 345 }} elevation={6}>
|
||||
<CardHeader
|
||||
avatar={
|
||||
<Avatar sx={{ bgcolor: red[500] }}>
|
||||
{activeEvent?.user.user_name
|
||||
.substring(0, 1)
|
||||
.toLocaleUpperCase()}
|
||||
</Avatar>
|
||||
}
|
||||
title={activeEvent?.user.user_name}
|
||||
subheader={activeEvent?.user.user_mail}
|
||||
/>
|
||||
|
||||
<CardContent>
|
||||
<Typography variant="body2" color="text.secondary">
|
||||
<p>
|
||||
Réservation de {activeEvent?.accommodation.name}
|
||||
<br />
|
||||
<em>{activeEvent?.accommodation.description}</em>
|
||||
</p>
|
||||
<p>
|
||||
Du{" "}
|
||||
{fmtUnixDate(
|
||||
activeEvent?.reservation.reservation_start ?? 0
|
||||
)}{" "}
|
||||
<br />
|
||||
Au{" "}
|
||||
{fmtUnixDate(
|
||||
activeEvent?.reservation.reservation_end ?? 0
|
||||
)}
|
||||
</p>
|
||||
<p>
|
||||
<strong>
|
||||
{activeEvent?.reservation.validated === false ? (
|
||||
<span style={{ color: "#f44336" }}>Refusée</span>
|
||||
) : activeEvent?.reservation.validated === true ? (
|
||||
<span style={{ color: "#66bb6a" }}>Validée</span>
|
||||
) : (
|
||||
<span style={{ color: "#29b6f6" }}>
|
||||
En attente de validation
|
||||
</span>
|
||||
)}
|
||||
</strong>
|
||||
</p>
|
||||
</Typography>
|
||||
</CardContent>
|
||||
<CardActions disableSpacing>
|
||||
{activeEvent?.accommodation.need_validation &&
|
||||
family.family.is_admin && (
|
||||
<>
|
||||
<Tooltip
|
||||
title="Valider (ou rejeter) la réservation"
|
||||
arrow
|
||||
>
|
||||
<IconButton
|
||||
onClick={(e) =>
|
||||
setValidateResaAnchorEl(e.currentTarget)
|
||||
}
|
||||
>
|
||||
<RuleIcon />
|
||||
</IconButton>
|
||||
</Tooltip>
|
||||
<Menu
|
||||
anchorEl={validateResaAnchorEl}
|
||||
open={!!validateResaAnchorEl && !!activeEvent}
|
||||
onClose={() => setValidateResaAnchorEl(null)}
|
||||
>
|
||||
<MenuItem
|
||||
disabled={
|
||||
activeEvent.reservation.validated === true
|
||||
}
|
||||
onClick={() =>
|
||||
validateReservation(activeEvent.reservation)
|
||||
}
|
||||
>
|
||||
Valider
|
||||
</MenuItem>
|
||||
<MenuItem
|
||||
disabled={
|
||||
activeEvent.reservation.validated === false
|
||||
}
|
||||
onClick={() =>
|
||||
rejectReservation(activeEvent.reservation)
|
||||
}
|
||||
>
|
||||
Rejeter
|
||||
</MenuItem>
|
||||
</Menu>
|
||||
</>
|
||||
)}
|
||||
|
||||
{user.user.id === activeEvent?.reservation.user_id && (
|
||||
<>
|
||||
<Tooltip title="Modifier les dates de réservation" arrow>
|
||||
<IconButton
|
||||
disabled={
|
||||
!activeEvent.accommodation.open_to_reservations
|
||||
}
|
||||
onClick={() =>
|
||||
changeReservation(activeEvent?.reservation)
|
||||
}
|
||||
>
|
||||
<EditIcon />
|
||||
</IconButton>
|
||||
</Tooltip>
|
||||
<Tooltip title="Supprimer la réservation" arrow>
|
||||
<IconButton
|
||||
color="error"
|
||||
onClick={() =>
|
||||
deleteReservation(activeEvent?.reservation)
|
||||
}
|
||||
>
|
||||
<DeleteIcon />
|
||||
</IconButton>
|
||||
</Tooltip>
|
||||
</>
|
||||
)}
|
||||
</CardActions>
|
||||
</Card>
|
||||
</Popover>
|
||||
</div>
|
||||
)}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
}
|
@ -0,0 +1,410 @@
|
||||
import AddIcon from "@mui/icons-material/Add";
|
||||
import CheckIcon from "@mui/icons-material/Check";
|
||||
import CloseIcon from "@mui/icons-material/Close";
|
||||
import HouseIcon from "@mui/icons-material/House";
|
||||
import {
|
||||
Alert,
|
||||
Button,
|
||||
Card,
|
||||
CardActions,
|
||||
CardContent,
|
||||
Typography,
|
||||
} from "@mui/material";
|
||||
import React from "react";
|
||||
import {
|
||||
Accommodation,
|
||||
AccommodationListApi,
|
||||
} from "../../../api/accommodations/AccommodationListApi";
|
||||
import {
|
||||
AccommodationCalendarURL,
|
||||
AccommodationsCalendarURLApi,
|
||||
} from "../../../api/accommodations/AccommodationsCalendarURLApi";
|
||||
import { useConfirm } from "../../../hooks/context_providers/ConfirmDialogProvider";
|
||||
import { useLoadingMessage } from "../../../hooks/context_providers/LoadingMessageProvider";
|
||||
import { useSnackbar } from "../../../hooks/context_providers/SnackbarProvider";
|
||||
import { useCreateAccommodationCalendarURL } from "../../../hooks/context_providers/accommodations/CreateAccommodationCalendarURLDialogProvider";
|
||||
import { useInstallCalendarDialog } from "../../../hooks/context_providers/accommodations/InstallCalendarDialogProvider";
|
||||
import { useUpdateAccommodation } from "../../../hooks/context_providers/accommodations/UpdateAccommodationDialogProvider";
|
||||
import { AsyncWidget } from "../../../widgets/AsyncWidget";
|
||||
import { useFamily } from "../../../widgets/BaseFamilyRoute";
|
||||
import { FamilyCard } from "../../../widgets/FamilyCard";
|
||||
import { TimeWidget } from "../../../widgets/TimeWidget";
|
||||
import { useAccommodations } from "../../../widgets/accommodations/BaseAccommodationsRoute";
|
||||
|
||||
const CARDS_WIDTH = "500px";
|
||||
|
||||
export function AccommodationsSettingsRoute(): React.ReactElement {
|
||||
return (
|
||||
<>
|
||||
<AccommodationsListCard />
|
||||
<AccommodationsCalURLsCard />
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
function AccommodationsListCard(): React.ReactElement {
|
||||
const loading = useLoadingMessage();
|
||||
const confirm = useConfirm();
|
||||
const snackbar = useSnackbar();
|
||||
|
||||
const family = useFamily();
|
||||
const accommodations = useAccommodations();
|
||||
|
||||
const [error, setError] = React.useState<string>();
|
||||
const [success, setSuccess] = React.useState<string>();
|
||||
|
||||
const updateAccommodation = useUpdateAccommodation();
|
||||
|
||||
const createAccommodation = async () => {
|
||||
setError(undefined);
|
||||
setSuccess(undefined);
|
||||
try {
|
||||
const accommodation = await updateAccommodation(
|
||||
{
|
||||
name: "",
|
||||
open_to_reservations: true,
|
||||
need_validation: false,
|
||||
color: "2196f3",
|
||||
},
|
||||
true
|
||||
);
|
||||
|
||||
if (!accommodation) return;
|
||||
|
||||
loading.show("Création du logement en cours...");
|
||||
|
||||
await AccommodationListApi.Create(family.family, accommodation);
|
||||
|
||||
snackbar("Le logement a été créé avec succès !");
|
||||
await accommodations.reloadAccommodationsList();
|
||||
} catch (e) {
|
||||
console.error("Failed to create accommodation!", e);
|
||||
setError(`Échec de la création du logement! ${e}`);
|
||||
} finally {
|
||||
loading.hide();
|
||||
}
|
||||
};
|
||||
|
||||
const requestUpdateAccommodation = async (a: Accommodation) => {
|
||||
setError(undefined);
|
||||
setSuccess(undefined);
|
||||
try {
|
||||
const update = await updateAccommodation(a, false);
|
||||
if (!update) return;
|
||||
|
||||
loading.show("Mise à jour du logement en cours...");
|
||||
|
||||
await AccommodationListApi.Update(a, update);
|
||||
|
||||
snackbar("Le logement a été créé avec succès !");
|
||||
await accommodations.reloadAccommodationsList();
|
||||
} catch (e) {
|
||||
console.error("Failed to update accommodation!", e);
|
||||
setError(`Échec de la mise à jour du logement! ${e}`);
|
||||
} finally {
|
||||
loading.hide();
|
||||
}
|
||||
};
|
||||
|
||||
const deleteAccommodation = async (a: Accommodation) => {
|
||||
setError(undefined);
|
||||
setSuccess(undefined);
|
||||
try {
|
||||
if (
|
||||
!(await confirm(
|
||||
`Voulez-vous vraiment supprimer le logement '${a.name}' ? Cette opération est définitive !`
|
||||
))
|
||||
)
|
||||
return;
|
||||
loading.show("Suppression du logement en cours...");
|
||||
|
||||
await AccommodationListApi.Delete(a);
|
||||
|
||||
snackbar("Le logement a été supprimé avec succès !");
|
||||
await accommodations.reloadAccommodationsList();
|
||||
} catch (e) {
|
||||
console.error("Failed to delete accommodation!", e);
|
||||
setError(`Échec de la suppression du logement! ${e}`);
|
||||
} finally {
|
||||
loading.hide();
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<FamilyCard error={error} success={success} style={{ width: CARDS_WIDTH }}>
|
||||
<CardContent>
|
||||
<Typography gutterBottom variant="h5" component="div">
|
||||
Logements
|
||||
</Typography>
|
||||
|
||||
{/* Display the list of accommodations */}
|
||||
{accommodations.accommodations.isEmpty && (
|
||||
<div style={{ textAlign: "center", margin: "25px" }}>
|
||||
Aucun logement enregistré pour le moment !
|
||||
</div>
|
||||
)}
|
||||
{accommodations.accommodations.fullList.map((a) => (
|
||||
<AccommodationCard
|
||||
accommodation={a}
|
||||
onRequestUpdate={requestUpdateAccommodation}
|
||||
onRequestDelete={deleteAccommodation}
|
||||
/>
|
||||
))}
|
||||
|
||||
{family.family.is_admin && (
|
||||
<Button
|
||||
startIcon={<AddIcon />}
|
||||
variant="outlined"
|
||||
color="info"
|
||||
fullWidth
|
||||
onClick={createAccommodation}
|
||||
size={"large"}
|
||||
>
|
||||
Ajouter un logement
|
||||
</Button>
|
||||
)}
|
||||
</CardContent>
|
||||
</FamilyCard>
|
||||
);
|
||||
}
|
||||
|
||||
function AccommodationCard(p: {
|
||||
accommodation: Accommodation;
|
||||
onRequestUpdate: (a: Accommodation) => void;
|
||||
onRequestDelete: (a: Accommodation) => void;
|
||||
}): React.ReactElement {
|
||||
const family = useFamily();
|
||||
return (
|
||||
<Card sx={{ minWidth: 275, margin: "10px 0px" }} variant="outlined">
|
||||
<CardContent>
|
||||
<Typography sx={{ fontSize: 14 }} color="text.secondary" gutterBottom>
|
||||
Mis à jour il y a <TimeWidget time={p.accommodation.time_update} />
|
||||
</Typography>
|
||||
<Typography variant="h5" component="div">
|
||||
<HouseIcon sx={{ color: "#" + p.accommodation.color }} />{" "}
|
||||
{p.accommodation.name}
|
||||
</Typography>
|
||||
<Typography sx={{ mb: 1.5 }} color="text.secondary">
|
||||
{p.accommodation.description}
|
||||
</Typography>
|
||||
<Typography variant="body2">
|
||||
<BoolIcon checked={p.accommodation.open_to_reservations} /> Ouvert aux
|
||||
réservations
|
||||
<br />
|
||||
<BoolIcon checked={!p.accommodation.need_validation} /> Réservation
|
||||
sans validation d'un administrateur
|
||||
</Typography>
|
||||
</CardContent>
|
||||
{family.family.is_admin && (
|
||||
<CardActions>
|
||||
<span style={{ flex: 1 }}></span>
|
||||
<Button
|
||||
size="small"
|
||||
onClick={() => p.onRequestUpdate(p.accommodation)}
|
||||
>
|
||||
Modifier
|
||||
</Button>
|
||||
<Button
|
||||
size="small"
|
||||
color="error"
|
||||
onClick={() => p.onRequestDelete(p.accommodation)}
|
||||
>
|
||||
Supprimer
|
||||
</Button>
|
||||
</CardActions>
|
||||
)}
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
|
||||
function BoolIcon(p: { checked?: boolean }): React.ReactElement {
|
||||
return p.checked ? (
|
||||
<CheckIcon color="success" />
|
||||
) : (
|
||||
<CloseIcon color="error" />
|
||||
);
|
||||
}
|
||||
|
||||
function AccommodationsCalURLsCard(): React.ReactElement {
|
||||
const key = React.useRef(0);
|
||||
|
||||
const confirm = useConfirm();
|
||||
const loading = useLoadingMessage();
|
||||
|
||||
const [error, setError] = React.useState<string>();
|
||||
const [success, setSuccess] = React.useState<string>();
|
||||
|
||||
const [list, setList] = React.useState<
|
||||
AccommodationCalendarURL[] | undefined
|
||||
>();
|
||||
|
||||
const family = useFamily();
|
||||
|
||||
const createCalendarURLDialog = useCreateAccommodationCalendarURL();
|
||||
const calendarURLDialog = useInstallCalendarDialog();
|
||||
|
||||
const load = async () => {
|
||||
setList(await AccommodationsCalendarURLApi.GetList(family.family));
|
||||
};
|
||||
|
||||
const reload = () => {
|
||||
key.current += 1;
|
||||
setList(undefined);
|
||||
};
|
||||
|
||||
const onRequestDelete = async (c: AccommodationCalendarURL) => {
|
||||
setError(undefined);
|
||||
setSuccess(undefined);
|
||||
try {
|
||||
if (
|
||||
!(await confirm(
|
||||
`Voulez-vous vraiment supprimer le calendrier '${c.name}' ? Cette opération est définitive !`
|
||||
))
|
||||
)
|
||||
return;
|
||||
|
||||
loading.show("Suppression du calendrier en cours...");
|
||||
|
||||
await AccommodationsCalendarURLApi.Delete(c);
|
||||
|
||||
setSuccess("Le calendrier a été supprimé avec succès !");
|
||||
reload();
|
||||
} catch (e) {
|
||||
console.error("Failed to delete accommodation!", e);
|
||||
setError(`Échec de la suppression du logement! ${e}`);
|
||||
} finally {
|
||||
loading.hide();
|
||||
}
|
||||
};
|
||||
|
||||
const createCalendarURL = async () => {
|
||||
try {
|
||||
const newCal = await createCalendarURLDialog();
|
||||
|
||||
if (!newCal) return;
|
||||
|
||||
loading.show("Création du calendrier en cours...");
|
||||
|
||||
const cal = await AccommodationsCalendarURLApi.Create(
|
||||
family.family,
|
||||
newCal
|
||||
);
|
||||
|
||||
setSuccess("Le calendrier a été créé avec succès !");
|
||||
|
||||
reload();
|
||||
|
||||
calendarURLDialog(cal);
|
||||
} catch (e) {
|
||||
console.error("Failed to create new accommodation calendar URL!", e);
|
||||
setError(`Échec de la création du calendrier! ${e}`);
|
||||
} finally {
|
||||
loading.hide();
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<FamilyCard error={error} success={success} style={{ width: CARDS_WIDTH }}>
|
||||
<CardContent>
|
||||
<Typography gutterBottom variant="h5" component="div">
|
||||
URL de calendriers
|
||||
</Typography>
|
||||
<Typography>
|
||||
Vous pouvez, si vous le souhaitez, importer dans votre application de
|
||||
calendrier le planning de réservation des logements. Pour ce faire, il
|
||||
vous suffit de créer une URL de calendrier.
|
||||
</Typography>
|
||||
|
||||
<Alert severity="info">
|
||||
Les calendriers créés ici ne sont visible que par vous. Vous ne pouvez
|
||||
pas manipuler les calendriers créés par les autres membres de la
|
||||
famille.
|
||||
</Alert>
|
||||
|
||||
<Button
|
||||
startIcon={<AddIcon />}
|
||||
variant="outlined"
|
||||
color="info"
|
||||
fullWidth
|
||||
onClick={createCalendarURL}
|
||||
size={"large"}
|
||||
>
|
||||
Créer un calendrier
|
||||
</Button>
|
||||
|
||||
<br />
|
||||
<br />
|
||||
|
||||
<AsyncWidget
|
||||
ready={list !== undefined}
|
||||
loadKey={key.current}
|
||||
load={load}
|
||||
errMsg="Echec du chargement de la liste des calendriers !"
|
||||
build={() =>
|
||||
list?.length === 0 ? (
|
||||
<>
|
||||
<p style={{ textAlign: "center" }}>
|
||||
Vous n'avez créé aucun calendrier pour le moment !
|
||||
</p>
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
{list?.map((c) => (
|
||||
<CalendarItem c={c} onRequestDelete={onRequestDelete} />
|
||||
))}
|
||||
</>
|
||||
)
|
||||
}
|
||||
/>
|
||||
</CardContent>
|
||||
</FamilyCard>
|
||||
);
|
||||
}
|
||||
|
||||
function CalendarItem(p: {
|
||||
c: AccommodationCalendarURL;
|
||||
onRequestDelete: (c: AccommodationCalendarURL) => void;
|
||||
}): React.ReactElement {
|
||||
const accommodations = useAccommodations();
|
||||
|
||||
const installCal = useInstallCalendarDialog();
|
||||
|
||||
return (
|
||||
<Card sx={{ minWidth: 275, margin: "10px 0px" }} variant="outlined">
|
||||
<CardContent>
|
||||
<Typography
|
||||
sx={{ fontSize: 14 }}
|
||||
color="text.secondary"
|
||||
gutterBottom
|
||||
></Typography>
|
||||
<Typography variant="h5" component="div">
|
||||
{p.c.name}
|
||||
</Typography>
|
||||
<Typography sx={{ mb: 1.5 }} color="text.secondary">
|
||||
{p.c.accommodation_id
|
||||
? accommodations.accommodations.get(p.c.accommodation_id)?.name
|
||||
: "Tous les logements"}
|
||||
</Typography>
|
||||
<Typography variant="body2">
|
||||
Créé il y a <TimeWidget time={p.c.time_create} />
|
||||
<br />
|
||||
Utilisé il y a <TimeWidget time={p.c.time_used} />
|
||||
</Typography>
|
||||
</CardContent>
|
||||
|
||||
<CardActions>
|
||||
<span style={{ flex: 1 }}></span>
|
||||
<Button size="small" onClick={() => installCal(p.c)}>
|
||||
Installer
|
||||
</Button>
|
||||
<Button
|
||||
size="small"
|
||||
color="error"
|
||||
onClick={() => p.onRequestDelete(p.c)}
|
||||
>
|
||||
Supprimer
|
||||
</Button>
|
||||
</CardActions>
|
||||
</Card>
|
||||
);
|
||||
}
|
@ -3,28 +3,31 @@ import DeleteIcon from "@mui/icons-material/Delete";
|
||||
import EditIcon from "@mui/icons-material/Edit";
|
||||
import FileDownloadIcon from "@mui/icons-material/FileDownload";
|
||||
import SaveIcon from "@mui/icons-material/Save";
|
||||
import { Button, Grid, Stack } from "@mui/material";
|
||||
import { Button, Stack } from "@mui/material";
|
||||
import Grid from "@mui/material/Grid";
|
||||
import React from "react";
|
||||
import { useNavigate, useParams } from "react-router-dom";
|
||||
import { Couple, CoupleApi } from "../../api/CoupleApi";
|
||||
import { Member } from "../../api/MemberApi";
|
||||
import { ServerApi } from "../../api/ServerApi";
|
||||
import { useAlert } from "../../hooks/context_providers/AlertDialogProvider";
|
||||
import { useConfirm } from "../../hooks/context_providers/ConfirmDialogProvider";
|
||||
import { useSnackbar } from "../../hooks/context_providers/SnackbarProvider";
|
||||
import { AsyncWidget } from "../../widgets/AsyncWidget";
|
||||
import { useFamily } from "../../widgets/BaseFamilyRoute";
|
||||
import { ConfirmLeaveWithoutSaveDialog } from "../../widgets/ConfirmLeaveWithoutSaveDialog";
|
||||
import { CouplePhoto } from "../../widgets/CouplePhoto";
|
||||
import { FamilyPageTitle } from "../../widgets/FamilyPageTitle";
|
||||
import { MemberItem } from "../../widgets/MemberItem";
|
||||
import { PropertiesBox } from "../../widgets/PropertiesBox";
|
||||
import { RouterLink } from "../../widgets/RouterLink";
|
||||
import { DateInput } from "../../widgets/forms/DateInput";
|
||||
import { MemberInput } from "../../widgets/forms/MemberInput";
|
||||
import { PropSelect } from "../../widgets/forms/PropSelect";
|
||||
import { UploadPhotoButton } from "../../widgets/forms/UploadPhotoButton";
|
||||
import { useQuery } from "../../hooks/useQuery";
|
||||
import { ServerApi } from "../../../api/ServerApi";
|
||||
import { Couple, CoupleApi } from "../../../api/genealogy/CoupleApi";
|
||||
import { Member } from "../../../api/genealogy/MemberApi";
|
||||
import { useAlert } from "../../../hooks/context_providers/AlertDialogProvider";
|
||||
import { useConfirm } from "../../../hooks/context_providers/ConfirmDialogProvider";
|
||||
import { useLoadingMessage } from "../../../hooks/context_providers/LoadingMessageProvider";
|
||||
import { useSnackbar } from "../../../hooks/context_providers/SnackbarProvider";
|
||||
import { useQuery } from "../../../hooks/useQuery";
|
||||
import { AsyncWidget } from "../../../widgets/AsyncWidget";
|
||||
import { useFamily } from "../../../widgets/BaseFamilyRoute";
|
||||
import { ConfirmLeaveWithoutSaveDialog } from "../../../widgets/ConfirmLeaveWithoutSaveDialog";
|
||||
import { CouplePhoto } from "../../../widgets/CouplePhoto";
|
||||
import { FamilyPageTitle } from "../../../widgets/FamilyPageTitle";
|
||||
import { MemberItem } from "../../../widgets/MemberItem";
|
||||
import { PropertiesBox } from "../../../widgets/PropertiesBox";
|
||||
import { RouterLink } from "../../../widgets/RouterLink";
|
||||
import { DateInput } from "../../../widgets/forms/DateInput";
|
||||
import { MemberInput } from "../../../widgets/forms/MemberInput";
|
||||
import { PropSelect } from "../../../widgets/forms/PropSelect";
|
||||
import { UploadPhotoButton } from "../../../widgets/forms/UploadPhotoButton";
|
||||
import { useGenealogy } from "../../../widgets/genealogy/BaseGenealogyRoute";
|
||||
|
||||
/**
|
||||
* Create a new couple route
|
||||
@ -35,6 +38,7 @@ export function FamilyCreateCoupleRoute(): React.ReactElement {
|
||||
|
||||
const [shouldQuit, setShouldQuit] = React.useState(false);
|
||||
const n = useNavigate();
|
||||
const genealogy = useGenealogy();
|
||||
const family = useFamily();
|
||||
|
||||
const params = useQuery();
|
||||
@ -48,7 +52,7 @@ export function FamilyCreateCoupleRoute(): React.ReactElement {
|
||||
try {
|
||||
const r = await CoupleApi.Create(m);
|
||||
|
||||
await family.reloadCouplesList();
|
||||
await genealogy.reloadCouplesList();
|
||||
|
||||
setShouldQuit(true);
|
||||
n(family.family.coupleURL(r));
|
||||
@ -61,7 +65,7 @@ export function FamilyCreateCoupleRoute(): React.ReactElement {
|
||||
|
||||
const cancel = () => {
|
||||
setShouldQuit(true);
|
||||
n(family.family.URL("couples"));
|
||||
n(family.family.URL("genealogy/couples"));
|
||||
};
|
||||
|
||||
return (
|
||||
@ -88,6 +92,7 @@ export function FamilyCoupleRoute(): React.ReactElement {
|
||||
const snackbar = useSnackbar();
|
||||
|
||||
const family = useFamily();
|
||||
const genealogy = useGenealogy();
|
||||
const { coupleId } = useParams();
|
||||
|
||||
const [couple, setCouple] = React.useState<Couple>();
|
||||
@ -99,7 +104,7 @@ export function FamilyCoupleRoute(): React.ReactElement {
|
||||
count.current += 1;
|
||||
setCouple(undefined);
|
||||
|
||||
await family.reloadCouplesList();
|
||||
await genealogy.reloadCouplesList();
|
||||
};
|
||||
|
||||
const deleteCouple = async () => {
|
||||
@ -114,9 +119,9 @@ export function FamilyCoupleRoute(): React.ReactElement {
|
||||
await CoupleApi.Delete(couple!);
|
||||
|
||||
snackbar("La fiche du couple a été supprimée avec succès !");
|
||||
n(family.family.URL("couples"));
|
||||
n(family.family.URL("genealogy/couples"));
|
||||
|
||||
await family.reloadCouplesList();
|
||||
await genealogy.reloadCouplesList();
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
alert("Échec de la suppression du couple !");
|
||||
@ -132,7 +137,7 @@ export function FamilyCoupleRoute(): React.ReactElement {
|
||||
build={() => (
|
||||
<CouplePage
|
||||
couple={couple!}
|
||||
children={family.members.childrenOfCouple(couple!)}
|
||||
children={genealogy.members.childrenOfCouple(couple!)}
|
||||
creating={false}
|
||||
editing={false}
|
||||
onRequestDelete={deleteCouple}
|
||||
@ -156,6 +161,7 @@ export function FamilyEditCoupleRoute(): React.ReactElement {
|
||||
|
||||
const [shouldQuit, setShouldQuit] = React.useState(false);
|
||||
|
||||
const genealogy = useGenealogy();
|
||||
const family = useFamily();
|
||||
|
||||
const [couple, setCouple] = React.useState<Couple>();
|
||||
@ -165,7 +171,8 @@ export function FamilyEditCoupleRoute(): React.ReactElement {
|
||||
|
||||
const cancel = () => {
|
||||
setShouldQuit(true);
|
||||
n(-1);
|
||||
n(family.family.coupleURL(couple!));
|
||||
//n(-1);
|
||||
};
|
||||
|
||||
const save = async (c: Couple) => {
|
||||
@ -174,7 +181,7 @@ export function FamilyEditCoupleRoute(): React.ReactElement {
|
||||
|
||||
snackbar("Les informations du couple ont été mises à jour avec succès !");
|
||||
|
||||
await family.reloadCouplesList();
|
||||
await genealogy.reloadCouplesList();
|
||||
|
||||
setShouldQuit(true);
|
||||
n(family.family.coupleURL(c, false));
|
||||
@ -210,13 +217,14 @@ export function CouplePage(p: {
|
||||
shouldAllowLeaving?: boolean;
|
||||
children?: Member[];
|
||||
onCancel?: () => void;
|
||||
onSave?: (m: Couple) => void;
|
||||
onSave?: (m: Couple) => Promise<void>;
|
||||
onRequestEdit?: () => void;
|
||||
onRequestDelete?: () => void;
|
||||
onForceReload?: () => void;
|
||||
}): React.ReactElement {
|
||||
const confirm = useConfirm();
|
||||
const snackbar = useSnackbar();
|
||||
const loadingMessage = useLoadingMessage();
|
||||
|
||||
const family = useFamily();
|
||||
|
||||
@ -230,8 +238,12 @@ export function CouplePage(p: {
|
||||
setCouple(new Couple(structuredClone(couple)));
|
||||
};
|
||||
|
||||
const save = () => {
|
||||
p.onSave!(couple);
|
||||
const save = async () => {
|
||||
loadingMessage.show(
|
||||
"Enregistrement des informations du couple en cours..."
|
||||
);
|
||||
await p.onSave!(couple);
|
||||
loadingMessage.hide();
|
||||
};
|
||||
|
||||
const cancel = async () => {
|
||||
@ -341,7 +353,7 @@ export function CouplePage(p: {
|
||||
|
||||
<Grid container spacing={2}>
|
||||
{/* General info */}
|
||||
<Grid item sm={12} md={6}>
|
||||
<Grid size={{ sm: 12, md: 6 }}>
|
||||
<PropertiesBox title="Informations générales">
|
||||
{/* Husband */}
|
||||
<br />
|
||||
@ -416,7 +428,7 @@ export function CouplePage(p: {
|
||||
|
||||
{
|
||||
/* Photo */ !family.family.disable_couple_photos && (
|
||||
<Grid item sm={12} md={6}>
|
||||
<Grid size={{ sm: 12, md: 6 }}>
|
||||
<PropertiesBox title="Photo">
|
||||
<div style={{ textAlign: "center" }}>
|
||||
<CouplePhoto couple={couple} width={150} />
|
||||
@ -463,7 +475,7 @@ export function CouplePage(p: {
|
||||
|
||||
{/* Children */}
|
||||
{p.children && (
|
||||
<Grid item sm={12} md={6}>
|
||||
<Grid size={{ sm: 12, md: 6 }}>
|
||||
<PropertiesBox title="Enfants">
|
||||
{p.children.length === 0 ? (
|
||||
<>Aucun enfant</>
|
||||
@ -479,7 +491,7 @@ export function CouplePage(p: {
|
||||
<div style={{ display: "flex", justifyContent: "end" }}>
|
||||
<RouterLink
|
||||
to={family.family.URL(
|
||||
`member/create?mother=${couple.wife}&father=${couple.husband}`
|
||||
`genealogy/member/create?mother=${couple.wife}&father=${couple.husband}`
|
||||
)}
|
||||
>
|
||||
<Button>Nouveau</Button>
|
@ -6,17 +6,18 @@ import { Button, TextField, Tooltip } from "@mui/material";
|
||||
import { DataGrid, GridActionsCellItem, GridColDef } from "@mui/x-data-grid";
|
||||
import React from "react";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { Couple, CoupleApi } from "../../api/CoupleApi";
|
||||
import { dateTimestamp, fmtDate } from "../../api/MemberApi";
|
||||
import { ServerApi } from "../../api/ServerApi";
|
||||
import { useAlert } from "../../hooks/context_providers/AlertDialogProvider";
|
||||
import { useConfirm } from "../../hooks/context_providers/ConfirmDialogProvider";
|
||||
import { useSnackbar } from "../../hooks/context_providers/SnackbarProvider";
|
||||
import { useFamily } from "../../widgets/BaseFamilyRoute";
|
||||
import { CouplePhoto } from "../../widgets/CouplePhoto";
|
||||
import { FamilyPageTitle } from "../../widgets/FamilyPageTitle";
|
||||
import { MemberPhoto } from "../../widgets/MemberPhoto";
|
||||
import { RouterLink } from "../../widgets/RouterLink";
|
||||
import { Couple, CoupleApi } from "../../../api/genealogy/CoupleApi";
|
||||
import { dateTimestamp, fmtDate } from "../../../api/genealogy/MemberApi";
|
||||
import { ServerApi } from "../../../api/ServerApi";
|
||||
import { useAlert } from "../../../hooks/context_providers/AlertDialogProvider";
|
||||
import { useConfirm } from "../../../hooks/context_providers/ConfirmDialogProvider";
|
||||
import { useSnackbar } from "../../../hooks/context_providers/SnackbarProvider";
|
||||
import { useFamily } from "../../../widgets/BaseFamilyRoute";
|
||||
import { CouplePhoto } from "../../../widgets/CouplePhoto";
|
||||
import { FamilyPageTitle } from "../../../widgets/FamilyPageTitle";
|
||||
import { MemberPhoto } from "../../../widgets/MemberPhoto";
|
||||
import { RouterLink } from "../../../widgets/RouterLink";
|
||||
import { useGenealogy } from "../../../widgets/genealogy/BaseGenealogyRoute";
|
||||
|
||||
export function FamilyCouplesListRoute(): React.ReactElement {
|
||||
const alert = useAlert();
|
||||
@ -24,6 +25,7 @@ export function FamilyCouplesListRoute(): React.ReactElement {
|
||||
const snackbar = useSnackbar();
|
||||
|
||||
const family = useFamily();
|
||||
const genealogy = useGenealogy();
|
||||
|
||||
const [filter, setFilter] = React.useState("");
|
||||
|
||||
@ -37,7 +39,7 @@ export function FamilyCouplesListRoute(): React.ReactElement {
|
||||
return;
|
||||
|
||||
await CoupleApi.Delete(c);
|
||||
await family.reloadCouplesList();
|
||||
await genealogy.reloadCouplesList();
|
||||
|
||||
snackbar("La fiche du couple a été supprimée avec succès !");
|
||||
} catch (e) {
|
||||
@ -63,7 +65,7 @@ export function FamilyCouplesListRoute(): React.ReactElement {
|
||||
</RouterLink>
|
||||
</div>
|
||||
|
||||
{family.couples.isEmpty ? (
|
||||
{genealogy.couples.isEmpty ? (
|
||||
<p>
|
||||
Votre famille n'a aucun couple enregistré pour le moment ! Utilisez le
|
||||
bouton situé en haut à droite pour créer le premier !
|
||||
@ -81,16 +83,16 @@ export function FamilyCouplesListRoute(): React.ReactElement {
|
||||
<CouplesTable
|
||||
couples={
|
||||
filter === ""
|
||||
? family.couples.fullList
|
||||
: family.couples.filter(
|
||||
? genealogy.couples.fullList
|
||||
: genealogy.couples.filter(
|
||||
(m) =>
|
||||
(m.wife &&
|
||||
family.members
|
||||
genealogy.members
|
||||
.get(m.wife)!
|
||||
.fullName.toLocaleLowerCase()
|
||||
.includes(filter.toLocaleLowerCase())) ||
|
||||
(m.husband &&
|
||||
family.members
|
||||
genealogy.members
|
||||
.get(m.husband)!
|
||||
.fullName.toLocaleLowerCase()
|
||||
.includes(filter.toLocaleLowerCase())) === true
|
||||
@ -109,14 +111,18 @@ function CouplesTable(p: {
|
||||
onDelete: (m: Couple) => void;
|
||||
}): React.ReactElement {
|
||||
const family = useFamily();
|
||||
const genealogy = useGenealogy();
|
||||
|
||||
const n = useNavigate();
|
||||
|
||||
const compareInvertedMembersNames = (
|
||||
v1: number | undefined,
|
||||
v2: number | undefined
|
||||
) => {
|
||||
const n1 = ((v1 && family.members.get(v1)?.invertedFullName) ?? "") || "";
|
||||
const n2 = ((v2 && family.members.get(v2)?.invertedFullName) ?? "") || "";
|
||||
const n1 =
|
||||
((v1 && genealogy.members.get(v1)?.invertedFullName) ?? "") || "";
|
||||
const n2 =
|
||||
((v2 && genealogy.members.get(v2)?.invertedFullName) ?? "") || "";
|
||||
|
||||
return n1?.localeCompare(n2, undefined, {
|
||||
ignorePunctuation: true,
|
||||
@ -132,7 +138,13 @@ function CouplesTable(p: {
|
||||
sortable: false,
|
||||
width: 60,
|
||||
renderCell(params) {
|
||||
return <CouplePhoto couple={params.row} />;
|
||||
return (
|
||||
<div
|
||||
style={{ display: "flex", alignItems: "center", height: "100%" }}
|
||||
>
|
||||
<CouplePhoto couple={params.row} />
|
||||
</div>
|
||||
);
|
||||
},
|
||||
},
|
||||
|
||||
@ -253,10 +265,10 @@ function CouplesTable(p: {
|
||||
}
|
||||
|
||||
function MemberCell(p: { id?: number }): React.ReactElement {
|
||||
const family = useFamily();
|
||||
const genealogy = useGenealogy();
|
||||
if (!p.id) return <></>;
|
||||
|
||||
const member = family.members.get(p.id!)!;
|
||||
const member = genealogy.members.get(p.id!)!;
|
||||
|
||||
return (
|
||||
<Tooltip title="Double-cliquez ici pour accéder à la fiche du membre">
|
16
geneit_app/src/routes/family/genealogy/FamilyHomeRoute.tsx
Normal file
16
geneit_app/src/routes/family/genealogy/FamilyHomeRoute.tsx
Normal file
@ -0,0 +1,16 @@
|
||||
import { FamilyPageTitle } from "../../../widgets/FamilyPageTitle";
|
||||
|
||||
export function FamilyHomeRoute(): React.ReactElement {
|
||||
return (
|
||||
<>
|
||||
<FamilyPageTitle title="Votre famille" />
|
||||
<div style={{ margin: "20px" }}>
|
||||
<p>
|
||||
Bienvenue sur l'espace informatique dédié à la vie de votre famille !
|
||||
Veuillez utiliser le menu situé à gauche pour accéder aux différentes
|
||||
sections de l'application.
|
||||
</p>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
@ -1,3 +1,5 @@
|
||||
import { mdiFamilyTree } from "@mdi/js";
|
||||
import Icon from "@mdi/react";
|
||||
import ClearIcon from "@mui/icons-material/Clear";
|
||||
import DeleteIcon from "@mui/icons-material/Delete";
|
||||
import EditIcon from "@mui/icons-material/Edit";
|
||||
@ -5,40 +7,40 @@ import FileDownloadIcon from "@mui/icons-material/FileDownload";
|
||||
import SaveIcon from "@mui/icons-material/Save";
|
||||
import {
|
||||
Button,
|
||||
Grid,
|
||||
ListItemAvatar,
|
||||
ListItemButton,
|
||||
ListItemText,
|
||||
Stack,
|
||||
} from "@mui/material";
|
||||
import Grid from "@mui/material/Grid";
|
||||
import * as EmailValidator from "email-validator";
|
||||
import React from "react";
|
||||
import { useNavigate, useParams } from "react-router-dom";
|
||||
import { Couple } from "../../api/CoupleApi";
|
||||
import { Member, MemberApi, fmtDate } from "../../api/MemberApi";
|
||||
import { ServerApi } from "../../api/ServerApi";
|
||||
import { useAlert } from "../../hooks/context_providers/AlertDialogProvider";
|
||||
import { useConfirm } from "../../hooks/context_providers/ConfirmDialogProvider";
|
||||
import { useSnackbar } from "../../hooks/context_providers/SnackbarProvider";
|
||||
import { AsyncWidget } from "../../widgets/AsyncWidget";
|
||||
import { useFamily } from "../../widgets/BaseFamilyRoute";
|
||||
import { ConfirmLeaveWithoutSaveDialog } from "../../widgets/ConfirmLeaveWithoutSaveDialog";
|
||||
import { CouplePhoto } from "../../widgets/CouplePhoto";
|
||||
import { FamilyPageTitle } from "../../widgets/FamilyPageTitle";
|
||||
import { MemberItem } from "../../widgets/MemberItem";
|
||||
import { MemberPhoto } from "../../widgets/MemberPhoto";
|
||||
import { PropertiesBox } from "../../widgets/PropertiesBox";
|
||||
import { RouterLink } from "../../widgets/RouterLink";
|
||||
import { DateInput } from "../../widgets/forms/DateInput";
|
||||
import { MemberInput } from "../../widgets/forms/MemberInput";
|
||||
import { PropCheckbox } from "../../widgets/forms/PropCheckbox";
|
||||
import { PropEdit } from "../../widgets/forms/PropEdit";
|
||||
import { PropSelect } from "../../widgets/forms/PropSelect";
|
||||
import { SexSelection } from "../../widgets/forms/SexSelection";
|
||||
import { UploadPhotoButton } from "../../widgets/forms/UploadPhotoButton";
|
||||
import { useQuery } from "../../hooks/useQuery";
|
||||
import { mdiFamilyTree } from "@mdi/js";
|
||||
import Icon from "@mdi/react";
|
||||
import { ServerApi } from "../../../api/ServerApi";
|
||||
import { Couple } from "../../../api/genealogy/CoupleApi";
|
||||
import { Member, MemberApi, fmtDate } from "../../../api/genealogy/MemberApi";
|
||||
import { useAlert } from "../../../hooks/context_providers/AlertDialogProvider";
|
||||
import { useConfirm } from "../../../hooks/context_providers/ConfirmDialogProvider";
|
||||
import { useLoadingMessage } from "../../../hooks/context_providers/LoadingMessageProvider";
|
||||
import { useSnackbar } from "../../../hooks/context_providers/SnackbarProvider";
|
||||
import { useQuery } from "../../../hooks/useQuery";
|
||||
import { AsyncWidget } from "../../../widgets/AsyncWidget";
|
||||
import { useFamily } from "../../../widgets/BaseFamilyRoute";
|
||||
import { ConfirmLeaveWithoutSaveDialog } from "../../../widgets/ConfirmLeaveWithoutSaveDialog";
|
||||
import { CouplePhoto } from "../../../widgets/CouplePhoto";
|
||||
import { FamilyPageTitle } from "../../../widgets/FamilyPageTitle";
|
||||
import { MemberItem } from "../../../widgets/MemberItem";
|
||||
import { MemberPhoto } from "../../../widgets/MemberPhoto";
|
||||
import { PropertiesBox } from "../../../widgets/PropertiesBox";
|
||||
import { RouterLink } from "../../../widgets/RouterLink";
|
||||
import { DateInput } from "../../../widgets/forms/DateInput";
|
||||
import { MemberInput } from "../../../widgets/forms/MemberInput";
|
||||
import { PropCheckbox } from "../../../widgets/forms/PropCheckbox";
|
||||
import { PropEdit } from "../../../widgets/forms/PropEdit";
|
||||
import { PropSelect } from "../../../widgets/forms/PropSelect";
|
||||
import { SexSelection } from "../../../widgets/forms/SexSelection";
|
||||
import { UploadPhotoButton } from "../../../widgets/forms/UploadPhotoButton";
|
||||
import { useGenealogy } from "../../../widgets/genealogy/BaseGenealogyRoute";
|
||||
|
||||
/**
|
||||
* Create a new member route
|
||||
@ -49,6 +51,7 @@ export function FamilyCreateMemberRoute(): React.ReactElement {
|
||||
|
||||
const [shouldQuit, setShouldQuit] = React.useState(false);
|
||||
const n = useNavigate();
|
||||
const genealogy = useGenealogy();
|
||||
const family = useFamily();
|
||||
|
||||
const parameters = useQuery();
|
||||
@ -59,10 +62,10 @@ export function FamilyCreateMemberRoute(): React.ReactElement {
|
||||
try {
|
||||
const r = await MemberApi.Create(m);
|
||||
|
||||
await family.reloadMembersList();
|
||||
await genealogy.reloadMembersList();
|
||||
|
||||
setShouldQuit(true);
|
||||
n(family.family.URL(`member/${r.id}`));
|
||||
n(family.family.URL(`genealogy/member/${r.id}`));
|
||||
snackbar(`La fiche pour ${r.fullName} a été créée avec succès !`);
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
@ -72,7 +75,7 @@ export function FamilyCreateMemberRoute(): React.ReactElement {
|
||||
|
||||
const cancel = () => {
|
||||
setShouldQuit(true);
|
||||
n(family.family.URL("members"));
|
||||
n(family.family.URL("genealogy/members"));
|
||||
};
|
||||
|
||||
const member = Member.New(family.family.family_id);
|
||||
@ -103,6 +106,7 @@ export function FamilyMemberRoute(): React.ReactElement {
|
||||
const snackbar = useSnackbar();
|
||||
|
||||
const family = useFamily();
|
||||
const genealogy = useGenealogy();
|
||||
const { memberId } = useParams();
|
||||
|
||||
const [member, setMember] = React.useState<Member>();
|
||||
@ -114,7 +118,7 @@ export function FamilyMemberRoute(): React.ReactElement {
|
||||
count.current += 1;
|
||||
setMember(undefined);
|
||||
|
||||
await family.reloadMembersList();
|
||||
await genealogy.reloadMembersList();
|
||||
};
|
||||
|
||||
const deleteMember = async () => {
|
||||
@ -129,9 +133,9 @@ export function FamilyMemberRoute(): React.ReactElement {
|
||||
await MemberApi.Delete(member!);
|
||||
|
||||
snackbar("La fiche de membre a été supprimée avec succès !");
|
||||
n(family.family.URL("members"));
|
||||
n(family.family.URL("genealogy/members"));
|
||||
|
||||
await family.reloadMembersList();
|
||||
await genealogy.reloadMembersList();
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
alert("Échec de la suppression du membre !");
|
||||
@ -147,16 +151,14 @@ export function FamilyMemberRoute(): React.ReactElement {
|
||||
build={() => (
|
||||
<MemberPage
|
||||
member={member!}
|
||||
children={family.members.children(member!.id)}
|
||||
siblings={family.members.siblings(member!.id)}
|
||||
couples={family.couples.getAllOf(member!)}
|
||||
children={genealogy.members.children(member!.id)}
|
||||
siblings={genealogy.members.siblings(member!.id)}
|
||||
couples={genealogy.couples.getAllOf(member!)}
|
||||
creating={false}
|
||||
editing={false}
|
||||
onrequestOpenTree={() => n(family.family.familyTreeURL(member!))}
|
||||
onRequestDelete={deleteMember}
|
||||
onRequestEdit={() =>
|
||||
n(family.family.URL(`member/${member!.id}/edit`))
|
||||
}
|
||||
onRequestEdit={() => n(family.family.memberURL(member!, true))}
|
||||
onForceReload={forceReload}
|
||||
/>
|
||||
)}
|
||||
@ -177,6 +179,7 @@ export function FamilyEditMemberRoute(): React.ReactElement {
|
||||
const [shouldQuit, setShouldQuit] = React.useState(false);
|
||||
|
||||
const family = useFamily();
|
||||
const genealogy = useGenealogy();
|
||||
|
||||
const [member, setMember] = React.useState<Member>();
|
||||
const load = async () => {
|
||||
@ -185,8 +188,8 @@ export function FamilyEditMemberRoute(): React.ReactElement {
|
||||
|
||||
const cancel = () => {
|
||||
setShouldQuit(true);
|
||||
//n(family.family.URL(`member/${member!.id}`));
|
||||
n(-1);
|
||||
n(family.family.memberURL(member!));
|
||||
//n(-1);
|
||||
};
|
||||
|
||||
const save = async (m: Member) => {
|
||||
@ -195,10 +198,10 @@ export function FamilyEditMemberRoute(): React.ReactElement {
|
||||
|
||||
snackbar("Les informations du membre ont été mises à jour avec succès !");
|
||||
|
||||
await family.reloadMembersList();
|
||||
await genealogy.reloadMembersList();
|
||||
|
||||
setShouldQuit(true);
|
||||
n(family.family.URL(`member/${member!.id}`));
|
||||
n(family.family.memberURL(member!));
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
alert("Échec de la mise à jour des informations du membre !");
|
||||
@ -233,7 +236,7 @@ export function MemberPage(p: {
|
||||
siblings?: Member[];
|
||||
couples?: Couple[];
|
||||
onCancel?: () => void;
|
||||
onSave?: (m: Member) => void;
|
||||
onSave?: (m: Member) => Promise<void>;
|
||||
onRequestEdit?: () => void;
|
||||
onRequestDelete?: () => void;
|
||||
onForceReload?: () => void;
|
||||
@ -241,6 +244,7 @@ export function MemberPage(p: {
|
||||
}): React.ReactElement {
|
||||
const confirm = useConfirm();
|
||||
const snackbar = useSnackbar();
|
||||
const loadingMessage = useLoadingMessage();
|
||||
|
||||
const family = useFamily();
|
||||
|
||||
@ -254,8 +258,12 @@ export function MemberPage(p: {
|
||||
setMember(new Member(structuredClone(member)));
|
||||
};
|
||||
|
||||
const save = () => {
|
||||
p.onSave!(member);
|
||||
const save = async () => {
|
||||
loadingMessage.show(
|
||||
"Enregistrement des informations du membre en cours..."
|
||||
);
|
||||
await p.onSave!(member);
|
||||
loadingMessage.hide();
|
||||
};
|
||||
|
||||
const cancel = async () => {
|
||||
@ -376,7 +384,7 @@ export function MemberPage(p: {
|
||||
|
||||
<Grid container spacing={2}>
|
||||
{/* General info */}
|
||||
<Grid item sm={12} md={6}>
|
||||
<Grid size={{ sm: 12, md: 6 }}>
|
||||
<PropertiesBox title="Informations générales">
|
||||
{/* Sex */}
|
||||
<SexSelection
|
||||
@ -496,7 +504,7 @@ export function MemberPage(p: {
|
||||
</Grid>
|
||||
|
||||
{/* Photo */}
|
||||
<Grid item sm={12} md={6}>
|
||||
<Grid size={{ sm: 12, md: 6 }}>
|
||||
<PropertiesBox title="Photo">
|
||||
<div style={{ textAlign: "center" }}>
|
||||
<MemberPhoto member={member} width={150} />
|
||||
@ -541,7 +549,7 @@ export function MemberPage(p: {
|
||||
|
||||
{/* Contact */}
|
||||
{(p.editing || member.hasContactInfo) && (
|
||||
<Grid item sm={12} md={6}>
|
||||
<Grid size={{ sm: 12, md: 6 }}>
|
||||
<PropertiesBox title="Contact">
|
||||
{/* Email */}
|
||||
<PropEdit
|
||||
@ -622,7 +630,7 @@ export function MemberPage(p: {
|
||||
|
||||
{/* Bio */}
|
||||
{(p.editing || member.hasNote) && (
|
||||
<Grid item sm={12} md={6}>
|
||||
<Grid size={{ sm: 12, md: 6 }}>
|
||||
<PropertiesBox title="Biographie">
|
||||
<PropEdit
|
||||
label="Biographie"
|
||||
@ -643,7 +651,7 @@ export function MemberPage(p: {
|
||||
|
||||
{/* Couples */}
|
||||
{p.couples && (
|
||||
<Grid item sm={12} md={6}>
|
||||
<Grid size={{ sm: 12, md: 6 }}>
|
||||
<PropertiesBox title={member.sex === "F" ? "Époux" : "Épouse"}>
|
||||
{p.couples!.length === 0 ? (
|
||||
<>{member.sex === "F" ? "Aucun époux" : "Aucune épouse"}</>
|
||||
@ -656,9 +664,9 @@ export function MemberPage(p: {
|
||||
<div style={{ display: "flex", justifyContent: "end" }}>
|
||||
<RouterLink
|
||||
to={family.family.URL(
|
||||
`couple/create?${member.sex === "F" ? "wife" : "husband"}=${
|
||||
member.id
|
||||
}`
|
||||
`genealogy/couple/create?${
|
||||
member.sex === "F" ? "wife" : "husband"
|
||||
}=${member.id}`
|
||||
)}
|
||||
>
|
||||
<Button>Nouveau</Button>
|
||||
@ -670,16 +678,13 @@ export function MemberPage(p: {
|
||||
|
||||
{/* Children */}
|
||||
{p.children && (
|
||||
<Grid item sm={12} md={6}>
|
||||
<Grid size={{ sm: 12, md: 6 }}>
|
||||
<PropertiesBox title="Enfants">
|
||||
{p.children.length === 0 ? (
|
||||
<>Aucun enfant</>
|
||||
) : (
|
||||
p.children.map((c) => (
|
||||
<RouterLink
|
||||
key={c.id}
|
||||
to={family.family.URL(`member/${c.id}`)}
|
||||
>
|
||||
<RouterLink key={c.id} to={family.family.memberURL(c)}>
|
||||
<MemberItem member={c} />
|
||||
</RouterLink>
|
||||
))
|
||||
@ -688,7 +693,7 @@ export function MemberPage(p: {
|
||||
<div style={{ display: "flex", justifyContent: "end" }}>
|
||||
<RouterLink
|
||||
to={family.family.URL(
|
||||
`member/create?${
|
||||
`genealogy/member/create?${
|
||||
member.sex === "F" ? "mother" : "father"
|
||||
}=${member.id}`
|
||||
)}
|
||||
@ -702,16 +707,13 @@ export function MemberPage(p: {
|
||||
|
||||
{/* Siblings */}
|
||||
{p.siblings && (
|
||||
<Grid item sm={12} md={6}>
|
||||
<Grid size={{ sm: 12, md: 6 }}>
|
||||
<PropertiesBox title="Frères et sœurs">
|
||||
{p.siblings.length === 0 ? (
|
||||
<>Aucun frère ou sœur</>
|
||||
) : (
|
||||
p.siblings.map((c) => (
|
||||
<RouterLink
|
||||
key={c.id}
|
||||
to={family.family.URL(`member/${c.id}`)}
|
||||
>
|
||||
<RouterLink key={c.id} to={family.family.memberURL(c)}>
|
||||
<MemberItem member={c} />
|
||||
</RouterLink>
|
||||
))
|
||||
@ -721,7 +723,7 @@ export function MemberPage(p: {
|
||||
<div style={{ display: "flex", justifyContent: "end" }}>
|
||||
<RouterLink
|
||||
to={family.family.URL(
|
||||
`member/create?mother=${member.mother}&father=${member.father}`
|
||||
`genealogy/member/create?mother=${member.mother}&father=${member.father}`
|
||||
)}
|
||||
>
|
||||
<Button>Nouveau</Button>
|
||||
@ -743,6 +745,7 @@ function CoupleItem(p: {
|
||||
const n = useNavigate();
|
||||
|
||||
const family = useFamily();
|
||||
const genealogy = useGenealogy();
|
||||
|
||||
const statusStr = ServerApi.Config.couples_states.find(
|
||||
(c) => c.code === p.couple.state
|
||||
@ -760,7 +763,7 @@ function CoupleItem(p: {
|
||||
const otherSpouseID =
|
||||
p.couple.wife === p.currMemberId ? p.couple.husband : p.couple.wife;
|
||||
const otherSpouse = otherSpouseID
|
||||
? family.members.get(otherSpouseID)
|
||||
? genealogy.members.get(otherSpouseID)
|
||||
: undefined;
|
||||
|
||||
return (
|
@ -21,18 +21,17 @@ import {
|
||||
buildAscendingTree,
|
||||
buildDescendingTree,
|
||||
treeHeight,
|
||||
} from "../../utils/family_tree";
|
||||
import { useFamily } from "../../widgets/BaseFamilyRoute";
|
||||
import { BasicFamilyTree } from "../../widgets/BasicFamilyTree";
|
||||
import { MemberItem } from "../../widgets/MemberItem";
|
||||
import { RouterLink } from "../../widgets/RouterLink";
|
||||
import { ComplexFamilyTree } from "../../widgets/complex_family_tree/ComplexFamilyTree";
|
||||
import { SimpleFamilyTree } from "../../widgets/simple_family_tree/SimpleFamilyTree";
|
||||
} from "../../../utils/family_tree";
|
||||
import { useFamily } from "../../../widgets/BaseFamilyRoute";
|
||||
import { BasicFamilyTree } from "../../../widgets/BasicFamilyTree";
|
||||
import { MemberItem } from "../../../widgets/MemberItem";
|
||||
import { RouterLink } from "../../../widgets/RouterLink";
|
||||
import { useGenealogy } from "../../../widgets/genealogy/BaseGenealogyRoute";
|
||||
import { SimpleFamilyTree } from "../../../widgets/simple_family_tree/SimpleFamilyTree";
|
||||
|
||||
enum CurrTab {
|
||||
BasicTree,
|
||||
SimpleTree,
|
||||
AdvancedTree,
|
||||
}
|
||||
|
||||
enum TreeMode {
|
||||
@ -43,22 +42,23 @@ enum TreeMode {
|
||||
export function FamilyMemberTreeRoute(): React.ReactElement {
|
||||
const { memberId } = useParams();
|
||||
|
||||
const genealogy = useGenealogy();
|
||||
const family = useFamily();
|
||||
|
||||
const [currTab, setCurrTab] = React.useState(CurrTab.SimpleTree);
|
||||
const [currMode, setCurrMode] = React.useState(TreeMode.Descending);
|
||||
|
||||
const member = family.members.get(Number(memberId));
|
||||
const member = genealogy.members.get(Number(memberId));
|
||||
|
||||
const memo: [FamilyTreeNode, number] | null = React.useMemo(() => {
|
||||
if (!member) return null;
|
||||
const tree =
|
||||
currMode === TreeMode.Ascending
|
||||
? buildAscendingTree(member.id, family.members, family.couples)
|
||||
: buildDescendingTree(member.id, family.members, family.couples);
|
||||
? buildAscendingTree(member.id, genealogy.members, genealogy.couples)
|
||||
: buildDescendingTree(member.id, genealogy.members, genealogy.couples);
|
||||
|
||||
return [tree, treeHeight(tree)];
|
||||
}, [member, currMode, family.members, family.couples]);
|
||||
}, [member, currMode, genealogy.members, genealogy.couples]);
|
||||
|
||||
const [currDepth, setCurrDepth] = React.useState(0);
|
||||
|
||||
@ -89,7 +89,7 @@ export function FamilyMemberTreeRoute(): React.ReactElement {
|
||||
dense
|
||||
member={member}
|
||||
secondary={
|
||||
<RouterLink to={family.family.URL("tree")}>
|
||||
<RouterLink to={family.family.URL("genealogy/tree")}>
|
||||
<IconButton>
|
||||
<ClearIcon />
|
||||
</IconButton>
|
||||
@ -149,7 +149,6 @@ export function FamilyMemberTreeRoute(): React.ReactElement {
|
||||
>
|
||||
<Tab tabIndex={CurrTab.BasicTree} label="Basique" />
|
||||
<Tab tabIndex={CurrTab.SimpleTree} label="Simple" />
|
||||
<Tab tabIndex={CurrTab.AdvancedTree} label="Avancé" />
|
||||
</Tabs>
|
||||
</div>
|
||||
|
||||
@ -157,14 +156,8 @@ export function FamilyMemberTreeRoute(): React.ReactElement {
|
||||
<Paper style={{ flex: "1", display: "flex", flexDirection: "column" }}>
|
||||
{currTab === CurrTab.BasicTree ? (
|
||||
<BasicFamilyTree tree={tree!} depth={currDepth} />
|
||||
) : currTab === CurrTab.SimpleTree ? (
|
||||
<SimpleFamilyTree tree={tree!} depth={currDepth} />
|
||||
) : (
|
||||
<ComplexFamilyTree
|
||||
tree={tree!}
|
||||
isUp={currMode === TreeMode.Ascending}
|
||||
depth={currDepth}
|
||||
/>
|
||||
<SimpleFamilyTree tree={tree!} depth={currDepth} />
|
||||
)}
|
||||
</Paper>
|
||||
</div>
|
@ -4,24 +4,31 @@ import EditIcon from "@mui/icons-material/Edit";
|
||||
import FemaleIcon from "@mui/icons-material/Female";
|
||||
import MaleIcon from "@mui/icons-material/Male";
|
||||
import VisibilityIcon from "@mui/icons-material/Visibility";
|
||||
import { Button, TextField, Tooltip } from "@mui/material";
|
||||
import { Button, TextField, Tooltip, Typography } from "@mui/material";
|
||||
import { DataGrid, GridActionsCellItem, GridColDef } from "@mui/x-data-grid";
|
||||
import React from "react";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { Member, MemberApi, dateTimestamp, fmtDate } from "../../api/MemberApi";
|
||||
import { useAlert } from "../../hooks/context_providers/AlertDialogProvider";
|
||||
import { useConfirm } from "../../hooks/context_providers/ConfirmDialogProvider";
|
||||
import { useSnackbar } from "../../hooks/context_providers/SnackbarProvider";
|
||||
import { useFamily } from "../../widgets/BaseFamilyRoute";
|
||||
import { FamilyPageTitle } from "../../widgets/FamilyPageTitle";
|
||||
import { MemberPhoto } from "../../widgets/MemberPhoto";
|
||||
import { RouterLink } from "../../widgets/RouterLink";
|
||||
import {
|
||||
Member,
|
||||
MemberApi,
|
||||
dateTimestamp,
|
||||
fmtDate,
|
||||
} from "../../../api/genealogy/MemberApi";
|
||||
import { useAlert } from "../../../hooks/context_providers/AlertDialogProvider";
|
||||
import { useConfirm } from "../../../hooks/context_providers/ConfirmDialogProvider";
|
||||
import { useSnackbar } from "../../../hooks/context_providers/SnackbarProvider";
|
||||
import { useFamily } from "../../../widgets/BaseFamilyRoute";
|
||||
import { FamilyPageTitle } from "../../../widgets/FamilyPageTitle";
|
||||
import { MemberPhoto } from "../../../widgets/MemberPhoto";
|
||||
import { RouterLink } from "../../../widgets/RouterLink";
|
||||
import { useGenealogy } from "../../../widgets/genealogy/BaseGenealogyRoute";
|
||||
|
||||
export function FamilyMembersListRoute(): React.ReactElement {
|
||||
const alert = useAlert();
|
||||
const confirm = useConfirm();
|
||||
const snackbar = useSnackbar();
|
||||
|
||||
const genealogy = useGenealogy();
|
||||
const family = useFamily();
|
||||
|
||||
const [filter, setFilter] = React.useState("");
|
||||
@ -36,7 +43,7 @@ export function FamilyMembersListRoute(): React.ReactElement {
|
||||
return;
|
||||
|
||||
await MemberApi.Delete(m);
|
||||
await family.reloadMembersList();
|
||||
await genealogy.reloadMembersList();
|
||||
|
||||
snackbar("La fiche du membre a été supprimée avec succès !");
|
||||
} catch (e) {
|
||||
@ -55,14 +62,14 @@ export function FamilyMembersListRoute(): React.ReactElement {
|
||||
}}
|
||||
>
|
||||
<FamilyPageTitle title="Membres de la famille" />
|
||||
<RouterLink to={family.family.URL("member/create")}>
|
||||
<RouterLink to={family.family.URL("genealogy/member/create")}>
|
||||
<Tooltip title="Créer la fiche d'un nouveau membre">
|
||||
<Button startIcon={<AddIcon />}>Nouveau</Button>
|
||||
</Tooltip>
|
||||
</RouterLink>
|
||||
</div>
|
||||
|
||||
{family.members.isEmpty ? (
|
||||
{genealogy.members.isEmpty ? (
|
||||
<p>
|
||||
Votre famille n'a aucun membre pour le moment ! Utilisez le bouton
|
||||
situé en haut à droite pour créer le premier !
|
||||
@ -80,8 +87,8 @@ export function FamilyMembersListRoute(): React.ReactElement {
|
||||
<MembersTable
|
||||
members={
|
||||
filter === ""
|
||||
? family.members.fullList
|
||||
: family.members.filter((m) =>
|
||||
? genealogy.members.fullList
|
||||
: genealogy.members.filter((m) =>
|
||||
m.fullName.toLowerCase().includes(filter.toLowerCase())
|
||||
)
|
||||
}
|
||||
@ -97,6 +104,7 @@ function MembersTable(p: {
|
||||
members: Member[];
|
||||
onDelete: (m: Member) => void;
|
||||
}): React.ReactElement {
|
||||
const genealogy = useGenealogy();
|
||||
const family = useFamily();
|
||||
const n = useNavigate();
|
||||
|
||||
@ -108,7 +116,13 @@ function MembersTable(p: {
|
||||
sortable: false,
|
||||
width: 60,
|
||||
renderCell(params) {
|
||||
return <MemberPhoto member={params.row} />;
|
||||
return (
|
||||
<div
|
||||
style={{ display: "flex", alignItems: "center", height: "100%" }}
|
||||
>
|
||||
<MemberPhoto member={params.row} />
|
||||
</div>
|
||||
);
|
||||
},
|
||||
},
|
||||
|
||||
@ -165,8 +179,13 @@ function MembersTable(p: {
|
||||
headerName: "Père",
|
||||
flex: 5,
|
||||
renderCell(params) {
|
||||
if (!params.row.father) return <></>;
|
||||
return family.members.get(params.row.father)!.fullName;
|
||||
if (!params.row.father)
|
||||
return (
|
||||
<Typography color="red" component="span" variant="body2">
|
||||
Non renseigné
|
||||
</Typography>
|
||||
);
|
||||
return genealogy.members.get(params.row.father)!.fullName;
|
||||
},
|
||||
},
|
||||
{
|
||||
@ -174,8 +193,13 @@ function MembersTable(p: {
|
||||
headerName: "Mère",
|
||||
flex: 5,
|
||||
renderCell(params) {
|
||||
if (!params.row.mother) return <></>;
|
||||
return family.members.get(params.row.mother)!.fullName;
|
||||
if (!params.row.mother)
|
||||
return (
|
||||
<Typography color="red" component="span" variant="body2">
|
||||
Non renseignée
|
||||
</Typography>
|
||||
);
|
||||
return genealogy.members.get(params.row.mother)!.fullName;
|
||||
},
|
||||
},
|
||||
{
|
@ -1,6 +1,6 @@
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { useFamily } from "../../widgets/BaseFamilyRoute";
|
||||
import { MemberInput } from "../../widgets/forms/MemberInput";
|
||||
import { useFamily } from "../../../widgets/BaseFamilyRoute";
|
||||
import { MemberInput } from "../../../widgets/forms/MemberInput";
|
||||
|
||||
export function FamilyTreeRoute(): React.ReactElement {
|
||||
const n = useNavigate();
|
221
geneit_app/src/routes/family/genealogy/GenalogySettingsRoute.tsx
Normal file
221
geneit_app/src/routes/family/genealogy/GenalogySettingsRoute.tsx
Normal file
@ -0,0 +1,221 @@
|
||||
import DownloadIcon from "@mui/icons-material/Download";
|
||||
import UploadIcon from "@mui/icons-material/Upload";
|
||||
import {
|
||||
Alert,
|
||||
Box,
|
||||
Button,
|
||||
CardActions,
|
||||
CardContent,
|
||||
FormControlLabel,
|
||||
Switch,
|
||||
Tooltip,
|
||||
Typography,
|
||||
} from "@mui/material";
|
||||
import React from "react";
|
||||
import { FamilyApi } from "../../../api/FamilyApi";
|
||||
import { DataApi } from "../../../api/genealogy/DataApi";
|
||||
import { useAlert } from "../../../hooks/context_providers/AlertDialogProvider";
|
||||
import { useConfirm } from "../../../hooks/context_providers/ConfirmDialogProvider";
|
||||
import { useLoadingMessage } from "../../../hooks/context_providers/LoadingMessageProvider";
|
||||
import { downloadBlob, selectFileToUpload } from "../../../utils/files_utils";
|
||||
import { useFamily } from "../../../widgets/BaseFamilyRoute";
|
||||
import { FamilyCard } from "../../../widgets/FamilyCard";
|
||||
|
||||
export function GenalogySettingsRoute(): React.ReactElement {
|
||||
return (
|
||||
<>
|
||||
<GenealogySettingsCard />
|
||||
<GenealogyExportCard />
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
function GenealogySettingsCard(): React.ReactElement {
|
||||
const alert = useAlert();
|
||||
|
||||
const family = useFamily();
|
||||
|
||||
const [disableCouplePhotos, setDisableCouplePhotos] = React.useState(
|
||||
family.family.disable_couple_photos
|
||||
);
|
||||
|
||||
const canEdit = family.family.is_admin;
|
||||
|
||||
const [error, setError] = React.useState<string>();
|
||||
const [success, setSuccess] = React.useState<string>();
|
||||
|
||||
const updateFamily = async () => {
|
||||
try {
|
||||
setError(undefined);
|
||||
setSuccess(undefined);
|
||||
|
||||
await FamilyApi.UpdateFamily({
|
||||
id: family.family.family_id,
|
||||
disable_couple_photos: disableCouplePhotos,
|
||||
});
|
||||
|
||||
family.reloadFamilyInfo();
|
||||
|
||||
alert("Les paramètres de la famille ont été mis à jour avec succès !");
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
setError("Echec de la mise à jour des paramètres de la famille !");
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<FamilyCard error={error} success={success}>
|
||||
<CardContent>
|
||||
<Typography gutterBottom variant="h5" component="div">
|
||||
Paramètres du module de généalogie
|
||||
</Typography>
|
||||
|
||||
<Box
|
||||
component="form"
|
||||
sx={{
|
||||
"& .MuiTextField-root": { my: 1 },
|
||||
}}
|
||||
noValidate
|
||||
autoComplete="off"
|
||||
>
|
||||
<Tooltip
|
||||
title="Les photos de couple ne sont pas utilisées en pratique dans les arbres généalogiques. Il est possible de masquer les formulaires d'édition de photos de couple pour limiter le risque de confusion."
|
||||
arrow
|
||||
>
|
||||
<FormControlLabel
|
||||
disabled={!canEdit}
|
||||
control={
|
||||
<Switch
|
||||
checked={disableCouplePhotos}
|
||||
onChange={(_e, c) => setDisableCouplePhotos(c)}
|
||||
/>
|
||||
}
|
||||
label="Désactiver les photos de couple"
|
||||
/>
|
||||
</Tooltip>
|
||||
</Box>
|
||||
</CardContent>
|
||||
<CardActions>
|
||||
<Button
|
||||
onClick={updateFamily}
|
||||
disabled={!canEdit}
|
||||
style={{ marginLeft: "auto" }}
|
||||
>
|
||||
Enregistrer
|
||||
</Button>
|
||||
</CardActions>
|
||||
</FamilyCard>
|
||||
);
|
||||
}
|
||||
|
||||
function GenealogyExportCard(): React.ReactElement {
|
||||
const loading = useLoadingMessage();
|
||||
const confirm = useConfirm();
|
||||
const alert = useAlert();
|
||||
|
||||
const family = useFamily();
|
||||
|
||||
const [error, setError] = React.useState<string>();
|
||||
const [success, setSuccess] = React.useState<string>();
|
||||
|
||||
const exportData = async () => {
|
||||
loading.show("Export des données");
|
||||
try {
|
||||
setError(undefined);
|
||||
setSuccess(undefined);
|
||||
|
||||
const blob = await DataApi.ExportData(family.familyId);
|
||||
downloadBlob(blob, `Export-${new Date().getTime()}.zip`);
|
||||
|
||||
setSuccess("Export des données effectué avec succès !");
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
setError("Echec de l'export des données de la famille !");
|
||||
}
|
||||
loading.hide();
|
||||
};
|
||||
|
||||
const importData = async () => {
|
||||
try {
|
||||
if (
|
||||
!(await confirm(
|
||||
"Attention ! Cette opération a pour effet d'effacer toutes les données existantes en base ! Voulez-vous vraiment poursuivre l'opération ?"
|
||||
))
|
||||
)
|
||||
return;
|
||||
|
||||
const file = await selectFileToUpload({
|
||||
allowedTypes: ["application/zip"],
|
||||
});
|
||||
if (file === null) return;
|
||||
|
||||
setError(undefined);
|
||||
setSuccess(undefined);
|
||||
|
||||
loading.show(
|
||||
"Restauration des données de généalogie de la famille en cours..."
|
||||
);
|
||||
|
||||
await DataApi.ImportData(family.familyId, file);
|
||||
|
||||
family.reloadFamilyInfo();
|
||||
|
||||
alert(
|
||||
"Import des données de généalogie de la famille effectué avec succès !"
|
||||
);
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
setError(
|
||||
`Echec de l'import des données de généalogie de la famille ! (${e})`
|
||||
);
|
||||
}
|
||||
|
||||
loading.hide();
|
||||
};
|
||||
|
||||
return (
|
||||
<FamilyCard error={error} success={success}>
|
||||
<CardContent>
|
||||
<Typography gutterBottom variant="h5" component="div">
|
||||
Export / import des données de généalogie
|
||||
</Typography>
|
||||
<p>
|
||||
Vous pouvez, à des fins de sauvegardes ou de transfert, exporter et
|
||||
importer l'ensemble des données des membres et des couples de cette
|
||||
famille, sous format ZIP.
|
||||
</p>
|
||||
|
||||
<Alert severity="warning">
|
||||
Attention ! La restauration des données de généalogie de la famille
|
||||
provoque préalablement l'effacement de toutes les données enregistrées
|
||||
dans la famille ! Par ailleurs, la restauration n'est pas réversible !
|
||||
</Alert>
|
||||
|
||||
<p> </p>
|
||||
|
||||
<Button
|
||||
startIcon={<DownloadIcon />}
|
||||
variant="outlined"
|
||||
fullWidth
|
||||
onClick={exportData}
|
||||
size={"large"}
|
||||
style={{ marginBottom: "10px" }}
|
||||
>
|
||||
Exporter les données de généalogie
|
||||
</Button>
|
||||
|
||||
<Button
|
||||
startIcon={<UploadIcon />}
|
||||
variant="outlined"
|
||||
color="warning"
|
||||
fullWidth
|
||||
onClick={importData}
|
||||
disabled={!family.family.is_admin}
|
||||
size={"large"}
|
||||
>
|
||||
Importer les données de généalogie
|
||||
</Button>
|
||||
</CardContent>
|
||||
</FamilyCard>
|
||||
);
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
import { FamilyPageTitle } from "../../../widgets/FamilyPageTitle";
|
||||
import { useGenealogy } from "../../../widgets/genealogy/BaseGenealogyRoute";
|
||||
|
||||
export function GenealogyHomeRoute(): React.ReactElement {
|
||||
const genealogy = useGenealogy();
|
||||
return (
|
||||
<>
|
||||
<FamilyPageTitle title="Généalogie de votre famille" />
|
||||
<div style={{ margin: "20px" }}>
|
||||
<p>
|
||||
Depuis cette section de l'application, vous pouvez afficher et
|
||||
compléter l'abre généalogique de votre famille.
|
||||
</p>
|
||||
<p> </p>
|
||||
<p>Nombre de fiches de membres: {genealogy.members.size}</p>
|
||||
<p>Nombre de fiches de couples: {genealogy.couples.size}</p>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
@ -1,5 +0,0 @@
|
||||
// jest-dom adds custom jest matchers for asserting on DOM nodes.
|
||||
// allows you to do things like:
|
||||
// expect(element).toHaveTextContent(/react/i)
|
||||
// learn more: https://github.com/testing-library/jest-dom
|
||||
import '@testing-library/jest-dom';
|
@ -1,3 +1,5 @@
|
||||
export function isDebug(): boolean {
|
||||
return !process.env.NODE_ENV || process.env.NODE_ENV === "development";
|
||||
return (
|
||||
!import.meta.env.NODE_ENV || import.meta.env.NODE_ENV === "development"
|
||||
);
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { Couple, CouplesList } from "../api/CoupleApi";
|
||||
import { Member, MembersList, dateTimestamp } from "../api/MemberApi";
|
||||
import { Couple, CouplesList } from "../api/genealogy/CoupleApi";
|
||||
import { Member, MembersList, dateTimestamp } from "../api/genealogy/MemberApi";
|
||||
|
||||
export interface CoupleInformation {
|
||||
couple: Couple;
|
||||
|
21
geneit_app/src/utils/form_utils.ts
Normal file
21
geneit_app/src/utils/form_utils.ts
Normal file
@ -0,0 +1,21 @@
|
||||
import { LenConstraint } from "../api/ServerApi";
|
||||
|
||||
/**
|
||||
* Check if a constraint was respected or not
|
||||
*
|
||||
* @returns An error message appropriate for the constraint
|
||||
* violation, if any, or undefined otherwise
|
||||
*/
|
||||
export function checkConstraint(
|
||||
constraint: LenConstraint,
|
||||
value: string | undefined
|
||||
): string | undefined {
|
||||
value = value ?? "";
|
||||
if (value.length < constraint.min)
|
||||
return `Veuillez indiquer au moins ${constraint.min} caractères !`;
|
||||
|
||||
if (value.length > constraint.max)
|
||||
return `Veuillez indiquer au maximum ${constraint.max} caractères !`;
|
||||
|
||||
return undefined;
|
||||
}
|
31
geneit_app/src/utils/time_utils.ts
Normal file
31
geneit_app/src/utils/time_utils.ts
Normal file
@ -0,0 +1,31 @@
|
||||
/**
|
||||
* Get formatted UNIX date
|
||||
*/
|
||||
export function fmtUnixDate(time: number): string {
|
||||
return new Date(time * 1000).toLocaleString("fr-FR");
|
||||
}
|
||||
|
||||
/**
|
||||
* Get formatted UNIX date for Full Calendar
|
||||
*/
|
||||
export function fmtUnixDateFullCalendar(
|
||||
time: number,
|
||||
correctEnd: boolean
|
||||
): string {
|
||||
let d = new Date(time * 1000);
|
||||
|
||||
if (d.getHours() > 0 && correctEnd)
|
||||
d = new Date(time * 1000 + 3600 * 24 * 1000);
|
||||
|
||||
const s = `${d.getFullYear()}-${(d.getMonth() + 1)
|
||||
.toString(10)
|
||||
.padStart(2, "0")}-${d.getDate().toString(10).padStart(2, "0")}`; /*T${d
|
||||
.getHours()
|
||||
.toString(10)
|
||||
.padStart(2, "0")}:${d.getMinutes().toString(10).padStart(2, "0")}:${d
|
||||
.getSeconds()
|
||||
.toString(10)
|
||||
.padStart(2, "0")}`*/
|
||||
|
||||
return s;
|
||||
}
|
1
geneit_app/src/vite-env.d.ts
vendored
Normal file
1
geneit_app/src/vite-env.d.ts
vendored
Normal file
@ -0,0 +1 @@
|
||||
/// <reference types="vite/client" />
|
@ -43,9 +43,13 @@ export function BaseAuthenticatedPage(): React.ReactElement {
|
||||
setAnchorEl(null);
|
||||
};
|
||||
|
||||
const signOut = () => {
|
||||
const signOut = async () => {
|
||||
handleCloseMenu();
|
||||
AuthApi.SignOut();
|
||||
try {
|
||||
await AuthApi.SignOut();
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
navigate("/");
|
||||
auth.setSignedIn(false);
|
||||
};
|
||||
|
@ -4,12 +4,15 @@ import {
|
||||
mdiContentCopy,
|
||||
mdiCrowd,
|
||||
mdiFamilyTree,
|
||||
mdiFileTree,
|
||||
mdiHomeGroup,
|
||||
mdiHumanMaleFemale,
|
||||
mdiLockCheck,
|
||||
mdiPlus,
|
||||
mdiRefresh,
|
||||
} from "@mdi/js";
|
||||
import Icon from "@mdi/react";
|
||||
import CalendarMonthIcon from "@mui/icons-material/CalendarMonth";
|
||||
import HomeIcon from "@mui/icons-material/Home";
|
||||
import {
|
||||
Box,
|
||||
@ -26,9 +29,7 @@ import {
|
||||
} from "@mui/material";
|
||||
import React from "react";
|
||||
import { Outlet, useLocation, useParams } from "react-router-dom";
|
||||
import { CoupleApi, CouplesList } from "../api/CoupleApi";
|
||||
import { ExtendedFamilyInfo, FamilyApi } from "../api/FamilyApi";
|
||||
import { MemberApi, MembersList } from "../api/MemberApi";
|
||||
import { useAlert } from "../hooks/context_providers/AlertDialogProvider";
|
||||
import { useConfirm } from "../hooks/context_providers/ConfirmDialogProvider";
|
||||
import { useSnackbar } from "../hooks/context_providers/SnackbarProvider";
|
||||
@ -37,12 +38,8 @@ import { RouterLink } from "./RouterLink";
|
||||
|
||||
interface FamilyContext {
|
||||
family: ExtendedFamilyInfo;
|
||||
members: MembersList;
|
||||
couples: CouplesList;
|
||||
familyId: number;
|
||||
reloadFamilyInfo: () => void;
|
||||
reloadMembersList: () => Promise<void>;
|
||||
reloadCouplesList: () => Promise<void>;
|
||||
}
|
||||
|
||||
const FamilyContextK = React.createContext<FamilyContext | null>(null);
|
||||
@ -54,25 +51,19 @@ export function BaseFamilyRoute(): React.ReactElement {
|
||||
const confirm = useConfirm();
|
||||
|
||||
const [family, setFamily] = React.useState<null | ExtendedFamilyInfo>(null);
|
||||
const [members, setMembers] = React.useState<null | MembersList>(null);
|
||||
const [couples, setCouples] = React.useState<null | CouplesList>(null);
|
||||
|
||||
const loadKey = React.useRef(1);
|
||||
|
||||
const loadPromise = React.useRef<() => void>();
|
||||
const loadPromise = React.useRef<() => void>(null);
|
||||
|
||||
const load = async () => {
|
||||
const familyID = Number(familyId);
|
||||
setFamily(await FamilyApi.GetSingle(familyID));
|
||||
setMembers(await MemberApi.GetEntireList(familyID));
|
||||
setCouples(await CoupleApi.GetEntireList(familyID));
|
||||
};
|
||||
|
||||
const onReload = async () => {
|
||||
loadKey.current += 1;
|
||||
setFamily(null);
|
||||
setMembers(null);
|
||||
setCouples(null);
|
||||
|
||||
return new Promise<void>((res, _rej) => {
|
||||
loadPromise.current = () => res();
|
||||
@ -106,26 +97,22 @@ export function BaseFamilyRoute(): React.ReactElement {
|
||||
|
||||
return (
|
||||
<AsyncWidget
|
||||
ready={family !== null && members !== null}
|
||||
ready={family !== null}
|
||||
loadKey={`${familyId}-${loadKey.current}`}
|
||||
load={load}
|
||||
errMsg="Échec du chargement des informations de la famille !"
|
||||
build={() => {
|
||||
if (loadPromise.current != null) {
|
||||
loadPromise.current?.();
|
||||
loadPromise.current = undefined;
|
||||
loadPromise.current = null;
|
||||
}
|
||||
|
||||
return (
|
||||
<FamilyContextK.Provider
|
||||
value={{
|
||||
family: family!,
|
||||
members: members!,
|
||||
couples: couples!,
|
||||
familyId: family!.family_id,
|
||||
reloadFamilyInfo: onReload,
|
||||
reloadMembersList: onReload,
|
||||
reloadCouplesList: onReload,
|
||||
}}
|
||||
>
|
||||
<Box
|
||||
@ -147,41 +134,75 @@ export function BaseFamilyRoute(): React.ReactElement {
|
||||
|
||||
<FamilyLink icon={<HomeIcon />} label="Accueil" uri="" />
|
||||
|
||||
<FamilyLink
|
||||
icon={<Icon path={mdiCrowd} size={1} />}
|
||||
label="Membres"
|
||||
uri="members"
|
||||
secondaryAction={
|
||||
<Tooltip title="Créer une nouvelle fiche de membre">
|
||||
<RouterLink to={family!.URL("member/create")}>
|
||||
<IconButton>
|
||||
<Icon path={mdiPlus} size={0.75} />
|
||||
</IconButton>
|
||||
</RouterLink>
|
||||
</Tooltip>
|
||||
}
|
||||
/>
|
||||
{family?.enable_genealogy && (
|
||||
<>
|
||||
<Divider sx={{ my: 1 }} />
|
||||
<ListSubheader component="div">Généalogie</ListSubheader>
|
||||
|
||||
<FamilyLink
|
||||
icon={<Icon path={mdiHumanMaleFemale} size={1} />}
|
||||
label="Couples"
|
||||
uri="couples"
|
||||
secondaryAction={
|
||||
<Tooltip title="Créer une nouvelle fiche de couple">
|
||||
<RouterLink to={family!.URL("couple/create")}>
|
||||
<IconButton>
|
||||
<Icon path={mdiPlus} size={0.75} />
|
||||
</IconButton>
|
||||
</RouterLink>
|
||||
</Tooltip>
|
||||
}
|
||||
/>
|
||||
<FamilyLink
|
||||
icon={<HomeIcon />}
|
||||
label="Accueil"
|
||||
uri="genealogy"
|
||||
/>
|
||||
<FamilyLink
|
||||
icon={<Icon path={mdiCrowd} size={1} />}
|
||||
label="Membres"
|
||||
uri="genealogy/members"
|
||||
secondaryAction={
|
||||
<Tooltip title="Créer une nouvelle fiche de membre">
|
||||
<RouterLink
|
||||
to={family!.URL("genealogy/member/create")}
|
||||
>
|
||||
<IconButton>
|
||||
<Icon path={mdiPlus} size={0.75} />
|
||||
</IconButton>
|
||||
</RouterLink>
|
||||
</Tooltip>
|
||||
}
|
||||
/>
|
||||
|
||||
<FamilyLink
|
||||
icon={<Icon path={mdiFamilyTree} size={1} />}
|
||||
label="Arbre"
|
||||
uri="tree"
|
||||
/>
|
||||
<FamilyLink
|
||||
icon={<Icon path={mdiHumanMaleFemale} size={1} />}
|
||||
label="Couples"
|
||||
uri="genealogy/couples"
|
||||
secondaryAction={
|
||||
<Tooltip title="Créer une nouvelle fiche de couple">
|
||||
<RouterLink
|
||||
to={family!.URL("genealogy/couple/create")}
|
||||
>
|
||||
<IconButton>
|
||||
<Icon path={mdiPlus} size={0.75} />
|
||||
</IconButton>
|
||||
</RouterLink>
|
||||
</Tooltip>
|
||||
}
|
||||
/>
|
||||
|
||||
<FamilyLink
|
||||
icon={<Icon path={mdiFamilyTree} size={1} />}
|
||||
label="Arbre"
|
||||
uri="genealogy/tree"
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
|
||||
{family?.enable_accommodations && (
|
||||
<>
|
||||
<Divider sx={{ my: 1 }} />
|
||||
<ListSubheader component="div">Logements</ListSubheader>
|
||||
|
||||
<FamilyLink
|
||||
icon={<HomeIcon />}
|
||||
label="Accueil"
|
||||
uri="accommodations"
|
||||
/>
|
||||
<FamilyLink
|
||||
icon={<CalendarMonthIcon />}
|
||||
label="Réservations"
|
||||
uri="accommodations/reservations"
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
|
||||
<Divider sx={{ my: 1 }} />
|
||||
<ListSubheader component="div">Administration</ListSubheader>
|
||||
@ -198,6 +219,22 @@ export function BaseFamilyRoute(): React.ReactElement {
|
||||
uri="settings"
|
||||
/>
|
||||
|
||||
{family?.enable_genealogy && (
|
||||
<FamilyLink
|
||||
icon={<Icon path={mdiFileTree} size={1} />}
|
||||
label="Généalogie"
|
||||
uri="genealogy/settings"
|
||||
/>
|
||||
)}
|
||||
|
||||
{family?.enable_accommodations && (
|
||||
<FamilyLink
|
||||
icon={<Icon path={mdiHomeGroup} size={1} />}
|
||||
label="Logements"
|
||||
uri="accommodations/settings"
|
||||
/>
|
||||
)}
|
||||
|
||||
{/* Invitation code */}
|
||||
|
||||
<ListItem
|
||||
|
@ -6,7 +6,6 @@ import CssBaseline from "@mui/material/CssBaseline";
|
||||
import Grid from "@mui/material/Grid";
|
||||
import Paper from "@mui/material/Paper";
|
||||
import Typography from "@mui/material/Typography";
|
||||
import * as React from "react";
|
||||
import { Link, Outlet } from "react-router-dom";
|
||||
import { DarkThemeButton } from "./DarkThemeButton";
|
||||
|
||||
@ -28,7 +27,8 @@ function Copyright(props: any) {
|
||||
style={{ color: "inherit" }}
|
||||
>
|
||||
Pierre HUBERT
|
||||
</a>{" "}
|
||||
</a>
|
||||
{" 2023-"}
|
||||
{new Date().getFullYear()}
|
||||
{"."}
|
||||
</Typography>
|
||||
@ -40,10 +40,7 @@ export function BaseLoginPage() {
|
||||
<Grid container component="main" sx={{ height: "100vh" }}>
|
||||
<CssBaseline />
|
||||
<Grid
|
||||
item
|
||||
xs={false}
|
||||
sm={4}
|
||||
md={7}
|
||||
size={{ xs: false, sm: 4, md: 7 }}
|
||||
sx={{
|
||||
backgroundImage: "url(/login_splash.jpg)",
|
||||
backgroundRepeat: "no-repeat",
|
||||
@ -55,7 +52,12 @@ export function BaseLoginPage() {
|
||||
backgroundPosition: "center",
|
||||
}}
|
||||
/>
|
||||
<Grid item xs={12} sm={8} md={5} component={Paper} elevation={6} square>
|
||||
<Grid
|
||||
size={{ xs: 12, sm: 8, md: 5 }}
|
||||
component={Paper}
|
||||
elevation={6}
|
||||
square
|
||||
>
|
||||
<Box
|
||||
sx={{
|
||||
my: 8,
|
||||
@ -82,7 +84,7 @@ export function BaseLoginPage() {
|
||||
variant="h6"
|
||||
style={{ margin: "10px 0px 30px 0px" }}
|
||||
>
|
||||
La généalogie de votre famille
|
||||
L'intranet de votre famille
|
||||
</Typography>
|
||||
|
||||
{/* inner page */}
|
||||
|
@ -2,11 +2,11 @@ import { mdiBabyCarriage, mdiCross } from "@mdi/js";
|
||||
import Icon from "@mdi/react";
|
||||
import ChevronRightIcon from "@mui/icons-material/ChevronRight";
|
||||
import ExpandMoreIcon from "@mui/icons-material/ExpandMore";
|
||||
import { TreeItem, TreeView } from "@mui/lab";
|
||||
import { TreeItem, SimpleTreeView } from "@mui/x-tree-view";
|
||||
import React from "react";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { Couple } from "../api/CoupleApi";
|
||||
import { Member, fmtDate } from "../api/MemberApi";
|
||||
import { Couple } from "../api/genealogy/CoupleApi";
|
||||
import { Member, fmtDate } from "../api/genealogy/MemberApi";
|
||||
import { FamilyTreeNode } from "../utils/family_tree";
|
||||
import { useFamily } from "./BaseFamilyRoute";
|
||||
import { MemberPhoto } from "./MemberPhoto";
|
||||
@ -16,13 +16,12 @@ export function BasicFamilyTree(p: {
|
||||
depth: number;
|
||||
}): React.ReactElement {
|
||||
return (
|
||||
<TreeView
|
||||
defaultCollapseIcon={<ExpandMoreIcon />}
|
||||
defaultExpandIcon={<ChevronRightIcon />}
|
||||
<SimpleTreeView
|
||||
slots={{ collapseIcon: ExpandMoreIcon, expandIcon: ChevronRightIcon }}
|
||||
sx={{ flexGrow: 1 }}
|
||||
>
|
||||
<FamilyTreeItem n={p.tree} depth={p.depth} />
|
||||
</TreeView>
|
||||
</SimpleTreeView>
|
||||
);
|
||||
}
|
||||
|
||||
@ -40,7 +39,7 @@ function FamilyTreeItem(p: {
|
||||
|
||||
return (
|
||||
<TreeItem
|
||||
nodeId={p.n.member.id.toString()}
|
||||
itemId={p.n.member.id.toString()}
|
||||
style={{ margin: "10px" }}
|
||||
label={
|
||||
<div style={{ display: "flex" }}>
|
||||
|
@ -11,7 +11,7 @@ import {
|
||||
} from "@mui/material";
|
||||
import React from "react";
|
||||
|
||||
import { unstable_useBlocker as useBlocker } from "react-router-dom";
|
||||
import { useBlocker } from "react-router-dom";
|
||||
|
||||
export function ConfirmLeaveWithoutSaveDialog(p: {
|
||||
shouldBlock: boolean;
|
||||
|
30
geneit_app/src/widgets/CopyToClipboard.tsx
Normal file
30
geneit_app/src/widgets/CopyToClipboard.tsx
Normal file
@ -0,0 +1,30 @@
|
||||
import { ButtonBase } from "@mui/material";
|
||||
import { PropsWithChildren } from "react";
|
||||
import { useSnackbar } from "../hooks/context_providers/SnackbarProvider";
|
||||
|
||||
export function CopyToClipboard(
|
||||
p: PropsWithChildren<{ content: string }>
|
||||
): React.ReactElement {
|
||||
const snackbar = useSnackbar();
|
||||
|
||||
const copy = () => {
|
||||
navigator.clipboard.writeText(p.content);
|
||||
snackbar(`${p.content} a été copié dans le presse papier.`);
|
||||
};
|
||||
|
||||
return (
|
||||
<ButtonBase
|
||||
onClick={copy}
|
||||
style={{
|
||||
display: "inline-block",
|
||||
alignItems: "unset",
|
||||
textAlign: "unset",
|
||||
position: "relative",
|
||||
padding: "0px",
|
||||
}}
|
||||
disableRipple
|
||||
>
|
||||
{p.children}
|
||||
</ButtonBase>
|
||||
);
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
import { Avatar } from "@mui/material";
|
||||
import { Couple } from "../api/CoupleApi";
|
||||
import { Couple } from "../api/genealogy/CoupleApi";
|
||||
|
||||
export function CouplePhoto(p: {
|
||||
couple: Couple;
|
||||
|
@ -2,10 +2,14 @@ import { Alert, Card } from "@mui/material";
|
||||
import { PropsWithChildren } from "react";
|
||||
|
||||
export function FamilyCard(
|
||||
p: PropsWithChildren<{ error?: string; success?: string }>
|
||||
p: PropsWithChildren<{
|
||||
error?: string;
|
||||
success?: string;
|
||||
style?: React.CSSProperties | undefined;
|
||||
}>
|
||||
): React.ReactElement {
|
||||
return (
|
||||
<Card style={{ margin: "10px auto", maxWidth: "450px" }}>
|
||||
<Card style={{ ...p.style, margin: "10px auto", maxWidth: "450px" }}>
|
||||
{p.error && <Alert severity="error">{p.error}</Alert>}
|
||||
{p.success && <Alert severity="success">{p.success}</Alert>}
|
||||
|
||||
|
@ -5,7 +5,7 @@ import {
|
||||
ListItemSecondaryAction,
|
||||
ListItemText,
|
||||
} from "@mui/material";
|
||||
import { Member, fmtDate } from "../api/MemberApi";
|
||||
import { Member, fmtDate } from "../api/genealogy/MemberApi";
|
||||
import { MemberPhoto } from "./MemberPhoto";
|
||||
import Icon from "@mdi/react";
|
||||
import FemaleIcon from "@mui/icons-material/Female";
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { Avatar } from "@mui/material";
|
||||
import { Member } from "../api/MemberApi";
|
||||
import { Member } from "../api/genealogy/MemberApi";
|
||||
|
||||
export function MemberPhoto(p: {
|
||||
member?: Member;
|
||||
|
@ -1,4 +1,5 @@
|
||||
import { Visibility, VisibilityOff } from "@mui/icons-material";
|
||||
import VisibilityIcon from "@mui/icons-material/Visibility";
|
||||
import VisibilityOffIcon from "@mui/icons-material/VisibilityOff";
|
||||
import {
|
||||
FormControl,
|
||||
FormHelperText,
|
||||
@ -50,7 +51,7 @@ export function PasswordInput(p: {
|
||||
onMouseDown={handleMouseDownPassword}
|
||||
edge="end"
|
||||
>
|
||||
{showPassword ? <VisibilityOff /> : <Visibility />}
|
||||
{showPassword ? <VisibilityOffIcon /> : <VisibilityIcon />}
|
||||
</IconButton>
|
||||
</InputAdornment>
|
||||
}
|
||||
|
@ -0,0 +1,84 @@
|
||||
import React from "react";
|
||||
import { Outlet } from "react-router-dom";
|
||||
import {
|
||||
AccommodationListApi,
|
||||
AccommodationsList,
|
||||
} from "../../api/accommodations/AccommodationListApi";
|
||||
import { CreateAccommodationCalendarURLDialogProvider } from "../../hooks/context_providers/accommodations/CreateAccommodationCalendarURLDialogProvider";
|
||||
import { InstallCalendarDialogProvider } from "../../hooks/context_providers/accommodations/InstallCalendarDialogProvider";
|
||||
import { UpdateAccommodationDialogProvider } from "../../hooks/context_providers/accommodations/UpdateAccommodationDialogProvider";
|
||||
import { UpdateReservationDialogProvider } from "../../hooks/context_providers/accommodations/UpdateReservationDialogProvider";
|
||||
import { AsyncWidget } from "../AsyncWidget";
|
||||
import { useFamily } from "../BaseFamilyRoute";
|
||||
|
||||
interface AccommodationsContext {
|
||||
accommodations: AccommodationsList;
|
||||
reloadAccommodationsList: () => Promise<void>;
|
||||
}
|
||||
|
||||
const AccommodationsContextK =
|
||||
React.createContext<AccommodationsContext | null>(null);
|
||||
|
||||
export function BaseAccommodationsRoute(): React.ReactElement {
|
||||
const family = useFamily();
|
||||
|
||||
const [accommodations, setAccommodations] =
|
||||
React.useState<null | AccommodationsList>(null);
|
||||
|
||||
const loadKey = React.useRef(1);
|
||||
|
||||
const loadPromise = React.useRef<() => void>(null);
|
||||
|
||||
const load = async () => {
|
||||
setAccommodations(
|
||||
await AccommodationListApi.GetListOfFamily(family.family)
|
||||
);
|
||||
};
|
||||
|
||||
const onReload = async () => {
|
||||
loadKey.current += 1;
|
||||
setAccommodations(null);
|
||||
|
||||
return new Promise<void>((res, _rej) => {
|
||||
loadPromise.current = () => res();
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<AsyncWidget
|
||||
ready={accommodations !== null}
|
||||
loadKey={`${family.familyId}-${loadKey.current}`}
|
||||
load={load}
|
||||
errMsg="Échec du chargement des informations sur les logements de la famille !"
|
||||
build={() => {
|
||||
if (loadPromise.current != null) {
|
||||
loadPromise.current?.();
|
||||
loadPromise.current = null;
|
||||
}
|
||||
|
||||
return (
|
||||
<AccommodationsContextK.Provider
|
||||
value={{
|
||||
accommodations: accommodations!,
|
||||
reloadAccommodationsList: onReload,
|
||||
}}
|
||||
>
|
||||
<UpdateAccommodationDialogProvider>
|
||||
<CreateAccommodationCalendarURLDialogProvider>
|
||||
<InstallCalendarDialogProvider>
|
||||
<UpdateReservationDialogProvider>
|
||||
<Outlet />
|
||||
</UpdateReservationDialogProvider>
|
||||
</InstallCalendarDialogProvider>
|
||||
</CreateAccommodationCalendarURLDialogProvider>
|
||||
</UpdateAccommodationDialogProvider>
|
||||
</AccommodationsContextK.Provider>
|
||||
);
|
||||
}}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
export function useAccommodations(): AccommodationsContext {
|
||||
return React.useContext(AccommodationsContextK)!;
|
||||
}
|
@ -1,339 +0,0 @@
|
||||
import { mdiXml } from "@mdi/js";
|
||||
import Icon from "@mdi/react";
|
||||
import PictureAsPdfIcon from "@mui/icons-material/PictureAsPdf";
|
||||
import { IconButton, Tooltip } from "@mui/material";
|
||||
import f3, { f3Data } from "family-chart";
|
||||
import { jsPDF } from "jspdf";
|
||||
import React from "react";
|
||||
import "svg2pdf.js";
|
||||
import { Couple } from "../../api/CoupleApi";
|
||||
import { Member, fmtDate } from "../../api/MemberApi";
|
||||
import { useDarkTheme } from "../../hooks/context_providers/DarkThemeProvider";
|
||||
import {
|
||||
FamilyTreeNode,
|
||||
getAvailableMembers,
|
||||
treeHeight,
|
||||
treeWidth,
|
||||
} from "../../utils/family_tree";
|
||||
import { downloadBlob } from "../../utils/files_utils";
|
||||
import "./family-chart.css";
|
||||
|
||||
export function ComplexFamilyTree(p: {
|
||||
tree: FamilyTreeNode;
|
||||
isUp: boolean;
|
||||
depth: number;
|
||||
}): React.ReactElement {
|
||||
const darkTheme = useDarkTheme();
|
||||
|
||||
const applyTree = (container: HTMLDivElement) => {
|
||||
if (!container) return;
|
||||
|
||||
const store = f3.createStore({
|
||||
data: treeToF3Data(p.tree, p.isUp, p.depth),
|
||||
node_separation: 250,
|
||||
level_separation: 150,
|
||||
});
|
||||
const view = f3.d3AnimationView({
|
||||
store,
|
||||
cont: container,
|
||||
});
|
||||
const Card = f3.elements.Card({
|
||||
store,
|
||||
svg: view.svg,
|
||||
card_dim: {
|
||||
w: 210,
|
||||
h: 120,
|
||||
text_x: 5,
|
||||
text_y: 75,
|
||||
img_w: 60,
|
||||
img_h: 70,
|
||||
img_x: 5,
|
||||
img_y: 5,
|
||||
},
|
||||
card_display: [
|
||||
(d) =>
|
||||
`${d.data.first_name || ""} ${d.data.last_name || ""} ${
|
||||
d.data.dead ? "✝" : ""
|
||||
}`,
|
||||
(d) => {
|
||||
let birthDeath = [];
|
||||
if (d.data.birthday) birthDeath.push(d.data.birthday);
|
||||
if (d.data.deathday) birthDeath.push(d.data.deathday);
|
||||
|
||||
let s = birthDeath.join(" -> ");
|
||||
|
||||
if (d.data.wedding_state || d.data.dateOfWedding) {
|
||||
let weddingInfo = [];
|
||||
if (d.data.wedding_state) weddingInfo.push(d.data.wedding_state);
|
||||
if (d.data.dateOfWedding)
|
||||
weddingInfo.push("Mariage : " + d.data.dateOfWedding);
|
||||
s += `</tspan> <tspan x="0" dy="14" font-size="10">${weddingInfo.join(
|
||||
" - "
|
||||
)}`;
|
||||
}
|
||||
|
||||
return s;
|
||||
},
|
||||
],
|
||||
mini_tree: true,
|
||||
link_break: false,
|
||||
});
|
||||
|
||||
// Patch generated card
|
||||
const PatchedCard: f3.F3CardBuilder = (p) => {
|
||||
const res = Card(p);
|
||||
|
||||
// Patch card colors for PDF export
|
||||
res
|
||||
.querySelector(".card-male")
|
||||
?.querySelector(".card-body-rect")
|
||||
?.setAttribute("fill", "#add8e6");
|
||||
res
|
||||
.querySelector(".card-female")
|
||||
?.querySelector(".card-body-rect")
|
||||
?.setAttribute("fill", "#ffb6c1");
|
||||
|
||||
return res;
|
||||
};
|
||||
|
||||
view.setCard(PatchedCard);
|
||||
store.setOnUpdate((props) => view.update(props || {}));
|
||||
store.update.tree({ initial: false, transition_time: 0 });
|
||||
};
|
||||
|
||||
const doExport = async (onlySVG: boolean) => {
|
||||
const docWidth = treeWidth(p.tree) * 65;
|
||||
const docHeight = treeHeight(p.tree) * 60;
|
||||
console.info(`Tree w=${treeWidth(p.tree)} h=${treeHeight(p.tree)}`);
|
||||
|
||||
// Clone the SVG to manipulate it
|
||||
const container = document.createElement("div");
|
||||
container.classList.add("f3", "f3-export");
|
||||
container.style.width = docWidth + "px";
|
||||
container.style.height = docHeight + "px";
|
||||
document.body.appendChild(container);
|
||||
applyTree(container);
|
||||
|
||||
const target = container.children[0];
|
||||
|
||||
await new Promise((res) => setTimeout(() => res(null), 100));
|
||||
|
||||
// SVG manipulations (adaptations to export)
|
||||
let dstSVG = target.innerHTML.replaceAll(
|
||||
`<path class="link" fill="none" stroke="#fff"`,
|
||||
`<path class="link" fill="none" stroke="#000"`
|
||||
);
|
||||
|
||||
dstSVG = dstSVG.replaceAll(
|
||||
`class="text-overflow-mask"`,
|
||||
`class="text-overflow-mask" fill="transparent"`
|
||||
);
|
||||
|
||||
dstSVG = dstSVG.replaceAll(`>UNKNOWN<`, `fill="#000">INCONNU<`);
|
||||
|
||||
dstSVG = dstSVG.replaceAll(
|
||||
`class="card-outline`,
|
||||
`fill="transparent" class="card-outline`
|
||||
);
|
||||
|
||||
dstSVG = dstSVG.replaceAll("✝", " ");
|
||||
|
||||
// Download in SVG format
|
||||
if (onlySVG) {
|
||||
// Fix background color (first rect background)
|
||||
dstSVG = dstSVG.replace(
|
||||
`fill="transparent"></rect>`,
|
||||
`fill="white"></rect>`
|
||||
);
|
||||
|
||||
const blob = new Blob([`<svg>${dstSVG}</svg>`], {
|
||||
type: "image/svg+xml",
|
||||
});
|
||||
|
||||
downloadBlob(blob, "ArbreGenealogique.svg");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Download in PDF format
|
||||
//navigator.clipboard.writeText(dstSVG);
|
||||
target.innerHTML = dstSVG;
|
||||
|
||||
const doc = new jsPDF({
|
||||
orientation: "l",
|
||||
format: [docHeight, docWidth],
|
||||
});
|
||||
|
||||
await doc.svg(target, {
|
||||
height: docHeight,
|
||||
width: docWidth,
|
||||
});
|
||||
|
||||
container.remove();
|
||||
|
||||
// Save the created pdf
|
||||
doc.save("ArbreGenealogique.pdf");
|
||||
};
|
||||
|
||||
const exportPDF = () => doExport(false);
|
||||
|
||||
const exportSVG = () => doExport(true);
|
||||
|
||||
return (
|
||||
<div>
|
||||
<div style={{ textAlign: "right" }}>
|
||||
<Tooltip title="Exporter le graphique au format PDF">
|
||||
<IconButton onClick={exportPDF}>
|
||||
<PictureAsPdfIcon />
|
||||
</IconButton>
|
||||
</Tooltip>
|
||||
<Tooltip title="Exporter le graphique au format SVG">
|
||||
<IconButton onClick={exportSVG}>
|
||||
<Icon path={mdiXml} size={1} />
|
||||
</IconButton>
|
||||
</Tooltip>
|
||||
</div>
|
||||
<div
|
||||
style={{ width: "100%" }}
|
||||
className={`f3 ${darkTheme.enabled ? "f3-dark" : "f3-light"}`}
|
||||
id="FamilyChart"
|
||||
ref={applyTree}
|
||||
></div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function treeToF3Data(
|
||||
node: FamilyTreeNode,
|
||||
isUp: boolean,
|
||||
depth: number
|
||||
): f3Data[] {
|
||||
const availableMembers = getAvailableMembers(node, depth);
|
||||
|
||||
const list: f3Data[] = [];
|
||||
if (isUp) treeToF3DataUpRecurse(node, list, availableMembers);
|
||||
else treeToF3DataDownRecurse(node, list, availableMembers);
|
||||
return list;
|
||||
}
|
||||
|
||||
function memberData(m: Member, c?: Couple): f3.f3DataData {
|
||||
return {
|
||||
first_name: m.first_name ?? "_",
|
||||
last_name: m.last_name ?? "_",
|
||||
gender: m.sex ?? "M",
|
||||
avatar: m.thumbnailURL ?? undefined,
|
||||
dead: m.dead,
|
||||
birthday: m.dateOfBirth ? fmtDate(m.dateOfBirth) : undefined,
|
||||
deathday: m.dateOfDeath ? fmtDate(m.dateOfDeath) : undefined,
|
||||
wedding_state: c?.stateFr,
|
||||
dateOfWedding: c?.dateOfWedding ? fmtDate(c?.dateOfWedding) : undefined,
|
||||
};
|
||||
}
|
||||
|
||||
function treeToF3DataUpRecurse(
|
||||
node: FamilyTreeNode,
|
||||
array: f3Data[],
|
||||
availableMembers: Set<number>,
|
||||
child?: number,
|
||||
spouses?: number[]
|
||||
) {
|
||||
if (!availableMembers.has(node.member.id)) return;
|
||||
|
||||
array.push({
|
||||
data: memberData(node.member),
|
||||
id: node.member.id.toString(),
|
||||
rels: {
|
||||
father:
|
||||
node.member.father && availableMembers.has(node.member.father)
|
||||
? node.member.father.toString()
|
||||
: undefined,
|
||||
mother:
|
||||
node.member.mother && availableMembers.has(node.member.mother)
|
||||
? node.member.mother.toString()
|
||||
: undefined,
|
||||
|
||||
spouses: spouses
|
||||
?.filter((c) => c !== node.member.id)
|
||||
.map((c) => c.toString()),
|
||||
children: child ? [child.toString()] : undefined,
|
||||
},
|
||||
});
|
||||
|
||||
const parentSpouses = node.down?.map((c) => c.member.id);
|
||||
|
||||
node.down?.forEach((d) =>
|
||||
treeToF3DataUpRecurse(
|
||||
d,
|
||||
array,
|
||||
availableMembers,
|
||||
node.member.id,
|
||||
parentSpouses
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
function treeToF3DataDownRecurse(
|
||||
node: FamilyTreeNode,
|
||||
array: f3Data[],
|
||||
availableMembers: Set<number>
|
||||
) {
|
||||
if (!availableMembers.has(node.member.id)) return;
|
||||
|
||||
// Get all members ids
|
||||
let children = node?.down?.map((c) => c.member.id) ?? [];
|
||||
node.couples?.map((c) => c.down.forEach((m) => children.push(m.member.id)));
|
||||
|
||||
children = children.filter((c) => availableMembers.has(c));
|
||||
|
||||
array.push({
|
||||
data: memberData(node.member),
|
||||
id: node.member.id.toString(),
|
||||
rels: {
|
||||
father:
|
||||
node.member.father && availableMembers.has(node.member.father)
|
||||
? node.member.father.toString()
|
||||
: undefined,
|
||||
mother:
|
||||
node.member.mother && availableMembers.has(node.member.mother)
|
||||
? node.member.mother.toString()
|
||||
: undefined,
|
||||
|
||||
spouses: node.couples
|
||||
?.filter((s) => availableMembers.has(s.member.id))
|
||||
.map((c) => c.member.id.toString()),
|
||||
children: children.map((c) => c.toString()),
|
||||
},
|
||||
});
|
||||
|
||||
node?.down?.forEach((e) =>
|
||||
treeToF3DataDownRecurse(e, array, availableMembers)
|
||||
);
|
||||
|
||||
if (node.couples) {
|
||||
for (const c of node.couples) {
|
||||
if (!availableMembers.has(c.member.id)) continue;
|
||||
array.push({
|
||||
data: memberData(c.member, c.couple),
|
||||
id: c.member.id.toString(),
|
||||
rels: {
|
||||
father:
|
||||
c.member.father && availableMembers.has(c.member.father)
|
||||
? c.member.father.toString()
|
||||
: undefined,
|
||||
mother:
|
||||
c.member.mother && availableMembers.has(c.member.mother)
|
||||
? c.member.mother.toString()
|
||||
: undefined,
|
||||
spouses: [node.member.id.toString()],
|
||||
children: c.down
|
||||
.filter((c) => availableMembers.has(c.member.id))
|
||||
.map((c) => c.member.id.toString()),
|
||||
},
|
||||
});
|
||||
|
||||
c.down.forEach((e) =>
|
||||
treeToF3DataDownRecurse(e, array, availableMembers)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,111 +0,0 @@
|
||||
.f3 {
|
||||
height: 700px;
|
||||
max-height: calc(100vh - 80px);
|
||||
width: 900px;
|
||||
max-width: 100%;
|
||||
margin: auto;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.f3 .cursor-pointer {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.f3 svg.main_svg {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
/*background-color: #3b5560;*/
|
||||
color: #3b5560;
|
||||
}
|
||||
.f3 svg.main_svg text {
|
||||
fill: currentColor;
|
||||
}
|
||||
.f3 rect.card-female,
|
||||
.f3 .card-female .card-body-rect,
|
||||
.f3 .card-female .text-overflow-mask {
|
||||
fill: lightpink;
|
||||
}
|
||||
.f3 rect.card-male,
|
||||
.f3 .card-male .card-body-rect,
|
||||
.f3 .card-male .text-overflow-mask {
|
||||
fill: lightblue;
|
||||
}
|
||||
.f3 .card-genderless .card-body-rect,
|
||||
.f3 .card-genderless .text-overflow-mask {
|
||||
fill: lightgray;
|
||||
}
|
||||
.f3 .card_add .card-body-rect {
|
||||
fill: #3b5560;
|
||||
stroke-width: 4px;
|
||||
stroke: #fff;
|
||||
cursor: pointer;
|
||||
}
|
||||
.f3 g.card_add text {
|
||||
fill: #fff;
|
||||
}
|
||||
.f3 .card-main {
|
||||
stroke: #000;
|
||||
}
|
||||
.f3 .card_family_tree rect {
|
||||
transition: 0.3s;
|
||||
}
|
||||
.f3 .card_family_tree:hover rect {
|
||||
transform: scale(1.1);
|
||||
}
|
||||
.f3 .card_add_relative {
|
||||
cursor: pointer;
|
||||
color: #fff;
|
||||
transition: 0.3s;
|
||||
}
|
||||
.f3 .card_add_relative circle {
|
||||
fill: rgba(0, 0, 0, 0);
|
||||
}
|
||||
.f3 .card_add_relative:hover {
|
||||
color: black;
|
||||
}
|
||||
.f3 .card_edit.pencil_icon {
|
||||
color: #fff;
|
||||
transition: 0.3s;
|
||||
}
|
||||
.f3 .card_edit.pencil_icon:hover {
|
||||
color: black;
|
||||
}
|
||||
.f3 .card_break_link,
|
||||
.f3 .link_upper,
|
||||
.f3 .link_lower,
|
||||
.f3 .link_particles {
|
||||
transform-origin: 50% 50%;
|
||||
transition: 1s;
|
||||
}
|
||||
.f3 .card_break_link {
|
||||
color: #fff;
|
||||
}
|
||||
.f3 .card_break_link.closed .link_upper {
|
||||
transform: translate(-140.5px, 655.6px);
|
||||
}
|
||||
.f3 .card_break_link.closed .link_upper g {
|
||||
transform: rotate(-58deg);
|
||||
}
|
||||
.f3 .card_break_link.closed .link_particles {
|
||||
transform: scale(0);
|
||||
}
|
||||
.f3 .input-field input {
|
||||
height: 2.5rem !important;
|
||||
}
|
||||
.f3 .input-field > label:not(.label-icon).active {
|
||||
-webkit-transform: translateY(-8px) scale(0.8);
|
||||
transform: translateY(-8px) scale(0.8);
|
||||
}
|
||||
|
||||
.f3-light .link {
|
||||
stroke: black;
|
||||
}
|
||||
|
||||
.f3-export {
|
||||
position: fixed;
|
||||
top: 0px;
|
||||
left: 0px;
|
||||
/*width: 3508px;
|
||||
height: 2480px;*/
|
||||
opacity: 0;
|
||||
}
|
@ -1,95 +0,0 @@
|
||||
declare module "family-chart" {
|
||||
type f3data = any;
|
||||
type f3tree = any;
|
||||
|
||||
interface f3Rels {
|
||||
spouses?: string[];
|
||||
father?: string;
|
||||
mother?: string;
|
||||
children?: string[];
|
||||
}
|
||||
|
||||
interface f3DataData {
|
||||
gender: "M" | "F";
|
||||
avatar?: string;
|
||||
dead: boolean;
|
||||
birthday?: string;
|
||||
deathday?: string;
|
||||
first_name: string;
|
||||
last_name: string;
|
||||
dateOfWedding?: string;
|
||||
wedding_state?: string;
|
||||
}
|
||||
|
||||
interface f3Data {
|
||||
id: string;
|
||||
rels: f3Rels;
|
||||
data: f3DataData;
|
||||
}
|
||||
|
||||
type f3State = {
|
||||
data: f3Data[];
|
||||
main_id?: any;
|
||||
tree?: f3tree;
|
||||
node_separation?: number;
|
||||
level_separation?: number;
|
||||
};
|
||||
|
||||
interface f3Update {
|
||||
tree: (props) => void;
|
||||
mainId: (mainId) => void;
|
||||
data: (data: f3data) => void;
|
||||
}
|
||||
|
||||
interface f3Store {
|
||||
state: f3State;
|
||||
update: f3update;
|
||||
getData: () => f3data;
|
||||
getTree: () => f3tree;
|
||||
setOnUpdate: (cb: (props) => void) => void;
|
||||
methods: any;
|
||||
}
|
||||
|
||||
function createStore(initial_state: f3State): f3Store;
|
||||
|
||||
function CalculateTree({
|
||||
data_stash,
|
||||
main_id = null,
|
||||
is_vertical = true,
|
||||
node_separation = 250,
|
||||
level_separation = 150,
|
||||
});
|
||||
|
||||
function d3AnimationView(p: {
|
||||
store: f3Store;
|
||||
cont: HTMLElement | null;
|
||||
Card?: any;
|
||||
});
|
||||
|
||||
const handlers: any;
|
||||
|
||||
type F3elements = {
|
||||
Card: (props: {
|
||||
store: f3Store;
|
||||
svg: HTMLElement;
|
||||
mini_tree: boolean;
|
||||
link_break: boolean;
|
||||
cardEditForm?: boolean;
|
||||
card_dim: {
|
||||
w: number;
|
||||
h: number;
|
||||
text_x: number;
|
||||
text_y: number;
|
||||
img_w: number;
|
||||
img_h: number;
|
||||
img_x: number;
|
||||
img_y: number;
|
||||
};
|
||||
card_display: ((data: f3Data) => string)[];
|
||||
}) => F3CardBuilder;
|
||||
};
|
||||
|
||||
type F3CardBuilder = (p: { node; d }) => HTMLElement;
|
||||
|
||||
const elements: F3elements;
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
import { Stack, TextField, Typography } from "@mui/material";
|
||||
import { NumberConstraint, ServerApi } from "../../api/ServerApi";
|
||||
import { DateValue, fmtDate } from "../../api/MemberApi";
|
||||
import { DateValue, fmtDate } from "../../api/genealogy/MemberApi";
|
||||
import { PropEdit } from "./PropEdit";
|
||||
|
||||
export function DateInput(p: {
|
||||
|
@ -2,9 +2,10 @@ import ClearIcon from "@mui/icons-material/Clear";
|
||||
import { Autocomplete, IconButton, TextField, Typography } from "@mui/material";
|
||||
import React from "react";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { Member } from "../../api/MemberApi";
|
||||
import { Member } from "../../api/genealogy/MemberApi";
|
||||
import { useFamily } from "../BaseFamilyRoute";
|
||||
import { MemberItem } from "../MemberItem";
|
||||
import { useGenealogy } from "../genealogy/BaseGenealogyRoute";
|
||||
|
||||
export function MemberInput(p: {
|
||||
editable: boolean;
|
||||
@ -15,13 +16,14 @@ export function MemberInput(p: {
|
||||
}): React.ReactElement {
|
||||
const n = useNavigate();
|
||||
const family = useFamily();
|
||||
const genealogy = useGenealogy();
|
||||
|
||||
const choices = family.members.filter(p.filter);
|
||||
const choices = genealogy.members.filter(p.filter);
|
||||
|
||||
const [inputValue, setInputValue] = React.useState("");
|
||||
|
||||
if (p.current) {
|
||||
const member = family.members.get(p.current)!;
|
||||
const member = genealogy.members.get(p.current)!;
|
||||
return (
|
||||
<div style={{ display: "flex", alignItems: "center" }}>
|
||||
<Typography variant="body2">{p.label}</Typography>
|
||||
@ -30,7 +32,7 @@ export function MemberInput(p: {
|
||||
onClick={
|
||||
!p.editable
|
||||
? () => {
|
||||
n(family.family.URL(`member/${member.id}`));
|
||||
n(family.family.memberURL(member));
|
||||
}
|
||||
: undefined
|
||||
}
|
||||
@ -55,7 +57,7 @@ export function MemberInput(p: {
|
||||
|
||||
return (
|
||||
<Autocomplete
|
||||
value={p.current ? family.members.get(p.current) : undefined}
|
||||
value={p.current ? genealogy.members.get(p.current) : undefined}
|
||||
onChange={(_event: any, newValue: Member | null | undefined) => {
|
||||
p.onValueChange(newValue?.id);
|
||||
}}
|
||||
|
@ -5,16 +5,20 @@ export function PropCheckbox(p: {
|
||||
label: string;
|
||||
checked: boolean | undefined;
|
||||
onValueChange: (v: boolean) => void;
|
||||
checkboxAlwaysVisible?: boolean;
|
||||
}): React.ReactElement {
|
||||
if (!p.editable && p.checked)
|
||||
return <Typography variant="body2">{p.label}</Typography>;
|
||||
if (!p.checkboxAlwaysVisible) {
|
||||
if (!p.editable && p.checked)
|
||||
return <Typography variant="body2">{p.label}</Typography>;
|
||||
|
||||
if (!p.editable) return <></>;
|
||||
if (!p.editable) return <></>;
|
||||
}
|
||||
|
||||
return (
|
||||
<FormControlLabel
|
||||
control={
|
||||
<Checkbox
|
||||
disabled={!p.editable}
|
||||
checked={p.checked}
|
||||
onChange={(e) => p.onValueChange(e.target.checked)}
|
||||
/>
|
||||
|
24
geneit_app/src/widgets/forms/PropColorPicker.tsx
Normal file
24
geneit_app/src/widgets/forms/PropColorPicker.tsx
Normal file
@ -0,0 +1,24 @@
|
||||
import { MuiColorInput } from "mui-color-input";
|
||||
import { PropEdit } from "./PropEdit";
|
||||
|
||||
export function PropColorPicker(p: {
|
||||
editable: boolean;
|
||||
label: string;
|
||||
value?: string;
|
||||
onChange: (v: string | undefined) => void;
|
||||
}): React.ReactElement {
|
||||
if (!p.editable) {
|
||||
if (!p.value) return <></>;
|
||||
|
||||
return <PropEdit editable={false} label={p.label} value={`#${p.value}`} />;
|
||||
}
|
||||
|
||||
return (
|
||||
<MuiColorInput
|
||||
value={"#" + (p.value ?? "")}
|
||||
fallbackValue="#ffffff"
|
||||
format="hex"
|
||||
onChange={(_v, c) => p.onChange(c.hex.substring(1))}
|
||||
/>
|
||||
);
|
||||
}
|
103
geneit_app/src/widgets/forms/PropDateInput.tsx
Normal file
103
geneit_app/src/widgets/forms/PropDateInput.tsx
Normal file
@ -0,0 +1,103 @@
|
||||
import { LocalizationProvider } from "@mui/x-date-pickers";
|
||||
import { AdapterDayjs } from "@mui/x-date-pickers/AdapterDayjs";
|
||||
import { DatePicker } from "@mui/x-date-pickers/DatePicker";
|
||||
import dayjs from "dayjs";
|
||||
import "dayjs/locale/fr";
|
||||
import { fmtUnixDate } from "../../utils/time_utils";
|
||||
import { PropEdit } from "./PropEdit";
|
||||
import { Checkbox, FormControlLabel } from "@mui/material";
|
||||
|
||||
export function PropDateInput(p: {
|
||||
editable: boolean;
|
||||
label: string;
|
||||
value: number | undefined;
|
||||
onChange: (v: number | undefined) => void;
|
||||
lastSecOfDay?: boolean;
|
||||
minDate?: number;
|
||||
maxDate?: number;
|
||||
canSetMiddleDay?: boolean;
|
||||
}): React.ReactElement {
|
||||
// Check for mid-day value
|
||||
let isMidDay = false;
|
||||
if (p.value) {
|
||||
const d = new Date(p.value * 1000);
|
||||
isMidDay =
|
||||
d.getHours() === 12 && d.getMinutes() === 0 && d.getSeconds() === 0;
|
||||
}
|
||||
|
||||
// Shift value
|
||||
let shiftV = p.value;
|
||||
if (shiftV && p.lastSecOfDay) {
|
||||
const d = new Date(shiftV * 1000);
|
||||
if (d.getHours() === 0) {
|
||||
shiftV -= 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (!p.editable) {
|
||||
if (!shiftV) return <></>;
|
||||
|
||||
return (
|
||||
<PropEdit editable={false} label={p.label} value={fmtUnixDate(shiftV)} />
|
||||
);
|
||||
}
|
||||
|
||||
const value = dayjs(
|
||||
shiftV && p.value! > 0 ? new Date(shiftV * 1000) : undefined
|
||||
);
|
||||
|
||||
const minDate = p.minDate ? dayjs(new Date(p.minDate * 1000)) : undefined;
|
||||
const maxDate = p.maxDate ? dayjs(new Date(p.maxDate * 1000)) : undefined;
|
||||
|
||||
return (
|
||||
<>
|
||||
<div style={{ height: "10px" }}></div>
|
||||
<LocalizationProvider dateAdapter={AdapterDayjs} adapterLocale="fr">
|
||||
<DatePicker
|
||||
label={p.label}
|
||||
value={value}
|
||||
onChange={(v) => {
|
||||
if (v && p.lastSecOfDay) {
|
||||
v = v.set("hours", 23);
|
||||
v = v.set("minutes", 59);
|
||||
v = v.set("seconds", 59);
|
||||
}
|
||||
p.onChange?.(v ? v.unix() : undefined);
|
||||
}}
|
||||
minDate={minDate}
|
||||
maxDate={maxDate}
|
||||
/>
|
||||
</LocalizationProvider>
|
||||
{p.canSetMiddleDay && (
|
||||
<FormControlLabel
|
||||
disabled={!p.value}
|
||||
control={
|
||||
<Checkbox
|
||||
checked={isMidDay}
|
||||
onChange={(_ev, midDay) => {
|
||||
let v = value;
|
||||
if (midDay) {
|
||||
v = v.set("hours", 12);
|
||||
v = v.set("minutes", 0);
|
||||
v = v.set("seconds", 0);
|
||||
} else if (p.lastSecOfDay) {
|
||||
v = v.set("hours", 23);
|
||||
v = v.set("minutes", 59);
|
||||
v = v.set("seconds", 59);
|
||||
} else {
|
||||
v = v.set("hours", 0);
|
||||
v = v.set("minutes", 0);
|
||||
v = v.set("seconds", 0);
|
||||
}
|
||||
|
||||
p.onChange(v.unix());
|
||||
}}
|
||||
/>
|
||||
}
|
||||
label="Mi-journée"
|
||||
/>
|
||||
)}
|
||||
<div style={{ height: "30px" }}></div>
|
||||
</>
|
||||
);
|
||||
}
|
@ -14,6 +14,7 @@ export function PropEdit(p: {
|
||||
multiline?: boolean;
|
||||
minRows?: number;
|
||||
maxRows?: number;
|
||||
helperText?: string;
|
||||
}): React.ReactElement {
|
||||
if (((!p.editable && p.value) ?? "") === "") return <></>;
|
||||
|
||||
@ -44,6 +45,7 @@ export function PropEdit(p: {
|
||||
!p.checkValue(p.value)) ||
|
||||
false
|
||||
}
|
||||
helperText={p.helperText}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ import { FormControl, InputLabel, MenuItem, Select } from "@mui/material";
|
||||
import { PropEdit } from "./PropEdit";
|
||||
|
||||
export interface SelectOption {
|
||||
value: string;
|
||||
value: string | undefined;
|
||||
label: string;
|
||||
}
|
||||
|
||||
@ -19,6 +19,7 @@ export function PropSelect(p: {
|
||||
const value = p.options.find((o) => o.value === p.value)?.label;
|
||||
return <PropEdit label={p.label} editable={p.editing} value={value} />;
|
||||
}
|
||||
|
||||
return (
|
||||
<FormControl fullWidth variant="filled" style={{ marginBottom: "15px" }}>
|
||||
<InputLabel>{p.label}</InputLabel>
|
||||
|
@ -6,7 +6,7 @@ import {
|
||||
Radio,
|
||||
Typography,
|
||||
} from "@mui/material";
|
||||
import { Sex } from "../../api/MemberApi";
|
||||
import { Sex } from "../../api/genealogy/MemberApi";
|
||||
|
||||
export function SexSelection(p: {
|
||||
readonly?: boolean;
|
||||
|
73
geneit_app/src/widgets/genealogy/BaseGenealogyRoute.tsx
Normal file
73
geneit_app/src/widgets/genealogy/BaseGenealogyRoute.tsx
Normal file
@ -0,0 +1,73 @@
|
||||
import React from "react";
|
||||
import { Outlet } from "react-router-dom";
|
||||
import { CoupleApi, CouplesList } from "../../api/genealogy/CoupleApi";
|
||||
import { MemberApi, MembersList } from "../../api/genealogy/MemberApi";
|
||||
import { AsyncWidget } from "../AsyncWidget";
|
||||
import { useFamily } from "../BaseFamilyRoute";
|
||||
|
||||
interface GenealogyContext {
|
||||
members: MembersList;
|
||||
couples: CouplesList;
|
||||
reloadMembersList: () => Promise<void>;
|
||||
reloadCouplesList: () => Promise<void>;
|
||||
}
|
||||
|
||||
const GenealogyContextK = React.createContext<GenealogyContext | null>(null);
|
||||
|
||||
export function BaseGenealogyRoute(): React.ReactElement {
|
||||
const family = useFamily();
|
||||
|
||||
const [members, setMembers] = React.useState<null | MembersList>(null);
|
||||
const [couples, setCouples] = React.useState<null | CouplesList>(null);
|
||||
|
||||
const loadKey = React.useRef(1);
|
||||
|
||||
const loadPromise = React.useRef<() => void>(null);
|
||||
|
||||
const load = async () => {
|
||||
setMembers(await MemberApi.GetEntireList(family.familyId));
|
||||
setCouples(await CoupleApi.GetEntireList(family.familyId));
|
||||
};
|
||||
|
||||
const onReload = async () => {
|
||||
loadKey.current += 1;
|
||||
setMembers(null);
|
||||
setCouples(null);
|
||||
|
||||
return new Promise<void>((res, _rej) => {
|
||||
loadPromise.current = () => res();
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<AsyncWidget
|
||||
ready={members !== null && couples !== null}
|
||||
loadKey={`${family.familyId}-${loadKey.current}`}
|
||||
load={load}
|
||||
errMsg="Échec du chargement des informations de généalogie de la famille !"
|
||||
build={() => {
|
||||
if (loadPromise.current != null) {
|
||||
loadPromise.current?.();
|
||||
loadPromise.current = null;
|
||||
}
|
||||
|
||||
return (
|
||||
<GenealogyContextK.Provider
|
||||
value={{
|
||||
members: members!,
|
||||
couples: couples!,
|
||||
reloadMembersList: onReload,
|
||||
reloadCouplesList: onReload,
|
||||
}}
|
||||
>
|
||||
<Outlet />
|
||||
</GenealogyContextK.Provider>
|
||||
);
|
||||
}}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
export function useGenealogy(): GenealogyContext {
|
||||
return React.useContext(GenealogyContextK)!;
|
||||
}
|
@ -5,14 +5,15 @@ import { IconButton, Tooltip } from "@mui/material";
|
||||
import jsPDF from "jspdf";
|
||||
import React from "react";
|
||||
import { TransformComponent, TransformWrapper } from "react-zoom-pan-pinch";
|
||||
import { Couple } from "../../api/CoupleApi";
|
||||
import { Member } from "../../api/MemberApi";
|
||||
import { Couple } from "../../api/genealogy/CoupleApi";
|
||||
import { Member } from "../../api/genealogy/MemberApi";
|
||||
import { useDarkTheme } from "../../hooks/context_providers/DarkThemeProvider";
|
||||
import { FamilyTreeNode } from "../../utils/family_tree";
|
||||
import { downloadBlob } from "../../utils/files_utils";
|
||||
import { getTextWidth } from "../../utils/render_utils";
|
||||
import "./simpletree.css";
|
||||
import "./Roboto-normal";
|
||||
import "svg2pdf.js";
|
||||
|
||||
const FACE_WIDTH = 60;
|
||||
const FACE_HEIGHT = 70;
|
||||
@ -92,7 +93,8 @@ function buildSimpleTreeNode(
|
||||
): SimpleTreeNode {
|
||||
if (depth === 0) throw new Error("Too much recursion reached!");
|
||||
|
||||
const lastCouple = tree.couples?.[tree.couples?.length - 1 ?? 0];
|
||||
const lastCoupleId = tree.couples?.length ?? 1;
|
||||
const lastCouple = tree.couples?.[lastCoupleId - 1];
|
||||
|
||||
// Preprocess children
|
||||
let childrenToProcess = tree.down;
|
||||
@ -254,6 +256,7 @@ function NodeArea(p: {
|
||||
let pers2 = p.node.spouse?.member;
|
||||
let didSwap = false;
|
||||
|
||||
// Show male of the left (all the time)
|
||||
if (pers2?.sex === "M") {
|
||||
let s = pers1;
|
||||
pers1 = pers2;
|
||||
@ -293,10 +296,37 @@ function NodeArea(p: {
|
||||
let childrenLinkX: number;
|
||||
let childrenLinkY: number;
|
||||
|
||||
if (p.node.spouse) {
|
||||
// If the father is the father of all the children, while the
|
||||
// mother is not the mother of any of the children
|
||||
if (
|
||||
pers2 &&
|
||||
p.node.down.every(
|
||||
(n) => n.member.father === pers1.id && n.member.mother !== pers2!.id
|
||||
)
|
||||
) {
|
||||
childrenLinkX = parent_x_offset + Math.floor(memberCardWidth(pers1) / 2);
|
||||
childrenLinkY = p.y + CARD_HEIGHT + 2;
|
||||
}
|
||||
// If the mother is the mother of all the children, while the
|
||||
// father is not the father of any of the children
|
||||
else if (
|
||||
pers2 &&
|
||||
p.node.down.every(
|
||||
(n) => n.member.father !== pers1.id && n.member.mother === pers2!.id
|
||||
)
|
||||
) {
|
||||
childrenLinkX = beginSecondFaceX! + Math.floor(memberCardWidth(pers2) / 2);
|
||||
childrenLinkY = p.y + CARD_HEIGHT + 2;
|
||||
}
|
||||
|
||||
// Normal couple
|
||||
else if (p.node.spouse) {
|
||||
childrenLinkX = Math.floor((endFirstFaceX + beginSecondFaceX!) / 2);
|
||||
childrenLinkY = middleParentFaceY;
|
||||
} else {
|
||||
}
|
||||
|
||||
// Single person
|
||||
else {
|
||||
childrenLinkX = parent_x_offset + Math.floor(memberCardWidth(pers1) / 2);
|
||||
childrenLinkY = p.y + CARD_HEIGHT + 2;
|
||||
}
|
||||
|
26
geneit_app/tsconfig.app.json
Normal file
26
geneit_app/tsconfig.app.json
Normal file
@ -0,0 +1,26 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
|
||||
"target": "ES2020",
|
||||
"useDefineForClassFields": true,
|
||||
"lib": ["ES2020", "DOM", "DOM.Iterable"],
|
||||
"module": "ESNext",
|
||||
"skipLibCheck": true,
|
||||
|
||||
/* Bundler mode */
|
||||
"moduleResolution": "bundler",
|
||||
"allowImportingTsExtensions": true,
|
||||
"isolatedModules": true,
|
||||
"moduleDetection": "force",
|
||||
"noEmit": true,
|
||||
"jsx": "react-jsx",
|
||||
|
||||
/* Linting */
|
||||
"strict": true,
|
||||
"noUnusedLocals": true,
|
||||
"noUnusedParameters": true,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"noUncheckedSideEffectImports": true
|
||||
},
|
||||
"include": ["src"]
|
||||
}
|
@ -1,26 +1,7 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "es5",
|
||||
"lib": [
|
||||
"dom",
|
||||
"dom.iterable",
|
||||
"esnext"
|
||||
],
|
||||
"allowJs": true,
|
||||
"skipLibCheck": true,
|
||||
"esModuleInterop": true,
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"strict": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"module": "esnext",
|
||||
"moduleResolution": "node",
|
||||
"resolveJsonModule": true,
|
||||
"isolatedModules": true,
|
||||
"noEmit": true,
|
||||
"jsx": "react-jsx"
|
||||
},
|
||||
"include": [
|
||||
"src"
|
||||
"files": [],
|
||||
"references": [
|
||||
{ "path": "./tsconfig.app.json" },
|
||||
{ "path": "./tsconfig.node.json" }
|
||||
]
|
||||
}
|
||||
|
24
geneit_app/tsconfig.node.json
Normal file
24
geneit_app/tsconfig.node.json
Normal file
@ -0,0 +1,24 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
|
||||
"target": "ES2022",
|
||||
"lib": ["ES2023"],
|
||||
"module": "ESNext",
|
||||
"skipLibCheck": true,
|
||||
|
||||
/* Bundler mode */
|
||||
"moduleResolution": "bundler",
|
||||
"allowImportingTsExtensions": true,
|
||||
"isolatedModules": true,
|
||||
"moduleDetection": "force",
|
||||
"noEmit": true,
|
||||
|
||||
/* Linting */
|
||||
"strict": true,
|
||||
"noUnusedLocals": true,
|
||||
"noUnusedParameters": true,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"noUncheckedSideEffectImports": true
|
||||
},
|
||||
"include": ["vite.config.ts"]
|
||||
}
|
@ -13,4 +13,4 @@ if [ ! "$DRONE_COMMIT_BRANCH" == "master" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
cd build && aws --endpoint-url https://s3.communiquons.org s3 sync . s3://geneit-app
|
||||
cd dist && aws --endpoint-url https://s3.communiquons.org s3 sync . s3://geneit-app
|
||||
|
7
geneit_app/vite.config.ts
Normal file
7
geneit_app/vite.config.ts
Normal file
@ -0,0 +1,7 @@
|
||||
import { defineConfig } from 'vite'
|
||||
import react from '@vitejs/plugin-react'
|
||||
|
||||
// https://vite.dev/config/
|
||||
export default defineConfig({
|
||||
plugins: [react()],
|
||||
})
|
3216
geneit_backend/Cargo.lock
generated
3216
geneit_backend/Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@ -1,39 +1,43 @@
|
||||
[package]
|
||||
name = "geneit_backend"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
edition = "2024"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
log = "0.4.17"
|
||||
env_logger = "0.10.0"
|
||||
clap = { version = "4.3.0", features = ["derive", "env"] }
|
||||
lazy_static = "1.4.0"
|
||||
anyhow = "1.0.75"
|
||||
actix-web = "4.3.1"
|
||||
actix-cors = "0.6.4"
|
||||
actix-multipart = "0.6.0"
|
||||
log = "0.4.27"
|
||||
env_logger = "0.11.8"
|
||||
clap = { version = "4.5.40", features = ["derive", "env"] }
|
||||
lazy_static = "1.5.0"
|
||||
lazy-regex = "3.4.1"
|
||||
anyhow = "1.0.98"
|
||||
actix-web = "4.10.2"
|
||||
actix-cors = "0.7.1"
|
||||
actix-multipart = "0.7.2"
|
||||
actix-remote-ip = "0.1.0"
|
||||
futures-util = "0.3.28"
|
||||
diesel = { version = "2.0.4", features = ["postgres"] }
|
||||
serde = { version = "1.0.188", features = ["derive"] }
|
||||
serde_json = "1.0.96"
|
||||
mailchecker = "5.0.9"
|
||||
redis = "0.23.2"
|
||||
lettre = "0.10.4"
|
||||
rand = "0.8.5"
|
||||
bcrypt = "0.15.0"
|
||||
light-openid = "1.0.1"
|
||||
thiserror = "1.0.47"
|
||||
serde_with = "3.1.0"
|
||||
rust_iso3166 = "0.1.10"
|
||||
rust-s3 = "0.33.0"
|
||||
sha2 = "0.10.7"
|
||||
image = "0.24.6"
|
||||
uuid = { version = "1.4.1", features = ["v4"] }
|
||||
httpdate = "1.0.2"
|
||||
zip = "0.6.6"
|
||||
mime_guess = "2.0.4"
|
||||
tempfile = "3.7.1"
|
||||
base64 = "0.21.2"
|
||||
futures-util = "0.3.31"
|
||||
diesel = { version = "2.2.11", features = ["postgres"] }
|
||||
diesel_migrations = "2.2.0"
|
||||
serde = { version = "1.0.219", features = ["derive"] }
|
||||
serde_json = "1.0.140"
|
||||
mailchecker = "6.0.17"
|
||||
redis = "0.29.5"
|
||||
lettre = "0.11.17"
|
||||
rand = "0.9.1"
|
||||
bcrypt = "0.17.0"
|
||||
light-openid = "1.0.4"
|
||||
thiserror = "2.0.12"
|
||||
serde_with = "3.12.0"
|
||||
rust_iso3166 = "0.1.14"
|
||||
rust-s3 = "0.35.1"
|
||||
sha2 = "0.10.9"
|
||||
image = "0.25.6"
|
||||
uuid = { version = "1.16.0", features = ["v4"] }
|
||||
httpdate = "1.0.3"
|
||||
zip = "2.5.0"
|
||||
mime_guess = "2.0.5"
|
||||
tempfile = "3.19.1"
|
||||
base64 = "0.22.1"
|
||||
ical = { version = "0.11.0", features = ["generator", "ical", "vcard"] }
|
||||
chrono = "0.4.41"
|
||||
|
@ -1,4 +1,4 @@
|
||||
FROM debian:bullseye-slim
|
||||
FROM debian:bookworm-slim
|
||||
|
||||
RUN apt-get update \
|
||||
&& apt-get install -y libcurl4 libpq5 \
|
||||
@ -6,4 +6,4 @@ RUN apt-get update \
|
||||
|
||||
COPY geneit_backend /usr/local/bin/geneit_backend
|
||||
|
||||
ENTRYPOINT /usr/local/bin/geneit_backend
|
||||
ENTRYPOINT ["/usr/local/bin/geneit_backend"]
|
||||
|
3
geneit_backend/build.rs
Normal file
3
geneit_backend/build.rs
Normal file
@ -0,0 +1,3 @@
|
||||
fn main() {
|
||||
println!("cargo:rerun-if-changed=migrations");
|
||||
}
|
@ -27,7 +27,7 @@ services:
|
||||
- ./storage/db:/var/lib/postgresql/data
|
||||
|
||||
mailcatcher:
|
||||
image: dockage/mailcatcher:0.8.2
|
||||
image: dockage/mailcatcher:0.9.0
|
||||
ports:
|
||||
- 1080:1080
|
||||
- 1025:1025
|
||||
|
@ -0,0 +1,3 @@
|
||||
-- Remove column to toggle genealogy
|
||||
ALTER TABLE public.families
|
||||
DROP COLUMN enable_genealogy;
|
@ -0,0 +1,5 @@
|
||||
-- Add column to toggle genealogy
|
||||
ALTER TABLE public.families
|
||||
ADD enable_genealogy boolean NOT NULL DEFAULT false;
|
||||
COMMENT
|
||||
ON COLUMN public.families.enable_genealogy IS 'Specify whether genealogy feature is enabled for the family';
|
@ -0,0 +1,6 @@
|
||||
ALTER TABLE public.families
|
||||
DROP COLUMN enable_accommodations;
|
||||
|
||||
DROP TABLE IF EXISTS accommodations_reservations_cals_urls;
|
||||
DROP TABLE IF EXISTS accommodations_reservations;
|
||||
DROP TABLE IF EXISTS accommodations_list;
|
@ -0,0 +1,52 @@
|
||||
-- Add column to toggle accommodations module
|
||||
ALTER TABLE public.families
|
||||
ADD enable_accommodations boolean NOT NULL DEFAULT false;
|
||||
COMMENT
|
||||
ON COLUMN public.families.enable_accommodations IS 'Specify whether accommodations feature is enabled for the family';
|
||||
|
||||
|
||||
-- Create tables
|
||||
CREATE TABLE IF NOT EXISTS accommodations_list
|
||||
(
|
||||
id SERIAL PRIMARY KEY,
|
||||
family_id integer NOT NULL REFERENCES families,
|
||||
time_create BIGINT NOT NULL,
|
||||
time_update BIGINT NOT NULL,
|
||||
name VARCHAR(50) NOT NULL,
|
||||
need_validation BOOLEAN NOT NULL DEFAULT true,
|
||||
description text NULL,
|
||||
color VARCHAR(6) NULL,
|
||||
open_to_reservations BOOLEAN NOT NULL DEFAULT false
|
||||
);
|
||||
|
||||
COMMENT ON COLUMN accommodations_list.need_validation is 'true if family admin review is required for validation. False otherwise';
|
||||
COMMENT ON COLUMN accommodations_list.open_to_reservations is 'true if reservations can be created / updated. False otherwise';
|
||||
|
||||
CREATE TABLE IF NOT EXISTS accommodations_reservations
|
||||
(
|
||||
id SERIAL PRIMARY KEY,
|
||||
family_id integer NOT NULL REFERENCES families ON DELETE CASCADE,
|
||||
accommodation_id integer NOT NULL REFERENCES accommodations_list ON DELETE CASCADE,
|
||||
user_id INTEGER NOT NULL REFERENCES users ON DELETE CASCADE,
|
||||
time_create BIGINT NOT NULL,
|
||||
time_update BIGINT NOT NULL,
|
||||
reservation_start BIGINT NOT NULL,
|
||||
reservation_end BIGINT NOT NULL,
|
||||
validated BOOLEAN NULL
|
||||
);
|
||||
|
||||
COMMENT ON COLUMN accommodations_reservations.validated is 'null if not reviewed yet. true if reservation is accepted. false if reservation is rejected';
|
||||
|
||||
CREATE TABLE IF NOT EXISTS accommodations_reservations_cals_urls
|
||||
(
|
||||
id SERIAL PRIMARY KEY,
|
||||
family_id integer NOT NULL REFERENCES families ON DELETE CASCADE,
|
||||
accommodation_id integer NULL REFERENCES accommodations_list ON DELETE CASCADE,
|
||||
user_id INTEGER NOT NULL REFERENCES users ON DELETE CASCADE,
|
||||
name VARCHAR(50) NOT NULL,
|
||||
token VARCHAR(50) NOT NULL,
|
||||
time_create BIGINT NOT NULL,
|
||||
time_used BIGINT NOT NULL
|
||||
);
|
||||
|
||||
COMMENT ON COLUMN accommodations_reservations_cals_urls.accommodation_id is 'null to get reservations of all accommodations. otherwise get the reservations of the specified accommodation only';
|
@ -194,6 +194,7 @@ impl AppConfig {
|
||||
db: self.redis_db_number,
|
||||
username: self.redis_username.clone(),
|
||||
password: Some(self.redis_password.clone()),
|
||||
protocol: Default::default(),
|
||||
},
|
||||
}
|
||||
}
|
||||
@ -245,7 +246,7 @@ impl AppConfig {
|
||||
}
|
||||
|
||||
/// Get S3 bucket
|
||||
pub fn s3_bucket(&self) -> anyhow::Result<Bucket> {
|
||||
pub fn s3_bucket(&self) -> anyhow::Result<Box<Bucket>> {
|
||||
Ok(Bucket::new(
|
||||
&self.s3_bucket_name,
|
||||
Region::Custom {
|
||||
|
@ -3,9 +3,13 @@
|
||||
use crate::app_config::AppConfig;
|
||||
use diesel::result::{DatabaseErrorKind, Error};
|
||||
use diesel::{Connection, PgConnection};
|
||||
use diesel_migrations::{EmbeddedMigrations, MigrationHarness, embed_migrations};
|
||||
use std::cell::RefCell;
|
||||
|
||||
const MIGRATIONS: EmbeddedMigrations = embed_migrations!();
|
||||
|
||||
thread_local! {
|
||||
static POSTGRES_CONNECTION: RefCell<Option<PgConnection>> = RefCell::new(None);
|
||||
static POSTGRES_CONNECTION: RefCell<Option<PgConnection>> = const { RefCell::new(None) };
|
||||
}
|
||||
|
||||
/// Execute a request on the database
|
||||
@ -39,3 +43,20 @@ where
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Initialize database connection
|
||||
pub fn initialize_conn() -> anyhow::Result<()> {
|
||||
// Run pending diesel migrations
|
||||
execute(|db| {
|
||||
let res = db
|
||||
.run_pending_migrations(MIGRATIONS)
|
||||
.expect("Failed to run database migration!");
|
||||
|
||||
for migration in res {
|
||||
log::info!("Executed database migration {migration}")
|
||||
}
|
||||
|
||||
Ok(())
|
||||
})?;
|
||||
Ok(())
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ use std::cell::RefCell;
|
||||
use std::time::Duration;
|
||||
|
||||
thread_local! {
|
||||
static REDIS_CONNECTION: RefCell<Option<redis::Client>> = RefCell::new(None);
|
||||
static REDIS_CONNECTION: RefCell<Option<redis::Client>> = const { RefCell::new(None) };
|
||||
}
|
||||
|
||||
/// Execute a request on Redis
|
||||
@ -45,14 +45,14 @@ where
|
||||
{
|
||||
let value_str = serde_json::to_string(value)?;
|
||||
|
||||
execute_request(|conn| Ok(conn.set_ex(key, value_str, lifetime.as_secs() as usize)?))?;
|
||||
execute_request(|conn| Ok(conn.set_ex::<_, _, ()>(key, value_str, lifetime.as_secs())?))?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Remove a value from Redis
|
||||
pub async fn remove_value(key: &str) -> anyhow::Result<()> {
|
||||
execute_request(|conn| Ok(conn.del(key)?))?;
|
||||
execute_request(|conn| Ok(conn.del::<_, ()>(key)?))?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
@ -22,11 +22,11 @@ pub async fn create_bucket_if_required() -> anyhow::Result<()> {
|
||||
log::debug!("The bucket already exists.");
|
||||
return Ok(());
|
||||
}
|
||||
Err(S3Error::Http(404, s)) if s.contains("<Code>NoSuchKey</Code>") => {
|
||||
Err(S3Error::HttpFailWithBody(404, s)) if s.contains("<Code>NoSuchKey</Code>") => {
|
||||
log::warn!("Failed to fetch bucket location, but it seems that bucket exists.");
|
||||
return Ok(());
|
||||
}
|
||||
Err(S3Error::Http(404, s)) if s.contains("<Code>NoSuchBucket</Code>") => {
|
||||
Err(S3Error::HttpFailWithBody(404, s)) if s.contains("<Code>NoSuchBucket</Code>") => {
|
||||
log::warn!("The bucket does not seem to exists, trying to create it!")
|
||||
}
|
||||
Err(e) => {
|
||||
|
@ -60,6 +60,10 @@ pub struct StaticConstraints {
|
||||
pub member_country: SizeConstraint,
|
||||
pub member_sex: SizeConstraint,
|
||||
pub member_note: SizeConstraint,
|
||||
|
||||
pub accommodation_name_len: SizeConstraint,
|
||||
pub accommodation_description_len: SizeConstraint,
|
||||
pub accommodation_calendar_name_len: SizeConstraint,
|
||||
}
|
||||
|
||||
impl Default for StaticConstraints {
|
||||
@ -91,6 +95,10 @@ impl Default for StaticConstraints {
|
||||
member_country: SizeConstraint::new(0, 2),
|
||||
member_sex: SizeConstraint::new(0, 1),
|
||||
member_note: SizeConstraint::new(0, 35000),
|
||||
|
||||
accommodation_name_len: SizeConstraint::new(1, 50),
|
||||
accommodation_description_len: SizeConstraint::new(0, 500),
|
||||
accommodation_calendar_name_len: SizeConstraint::new(2, 50),
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -134,3 +142,10 @@ pub const THUMB_WIDTH: u32 = 350;
|
||||
|
||||
/// Thumbnail height
|
||||
pub const THUMB_HEIGHT: u32 = 350;
|
||||
|
||||
/// Accommodations reservations calendars tokens len
|
||||
pub const ACCOMMODATIONS_RESERVATIONS_CALENDARS_TOKENS_LEN: usize = 50;
|
||||
|
||||
/// Minimum interval before calendar used time update
|
||||
pub const ACCOMMODATIONS_RESERVATIONS_CAL_URL_TIME_USED_UPDATE_MIN_INTERVAL: Duration =
|
||||
Duration::from_secs(60);
|
||||
|
115
geneit_backend/src/controllers/accommodations_list_controller.rs
Normal file
115
geneit_backend/src/controllers/accommodations_list_controller.rs
Normal file
@ -0,0 +1,115 @@
|
||||
use crate::constants::StaticConstraints;
|
||||
use crate::controllers::HttpResult;
|
||||
use crate::extractors::accommodation_extractor::FamilyAndAccommodationInPath;
|
||||
use crate::extractors::family_extractor::{FamilyInPath, FamilyInPathWithAdminMembership};
|
||||
use crate::models::Accommodation;
|
||||
use crate::services::accommodations_list_service;
|
||||
use actix_web::{HttpResponse, web};
|
||||
|
||||
#[derive(thiserror::Error, Debug)]
|
||||
enum AccommodationListControllerErr {
|
||||
#[error("Invalid name length!")]
|
||||
InvalidNameLength,
|
||||
#[error("Invalid description length!")]
|
||||
InvalidDescriptionLength,
|
||||
#[error("Malformed color!")]
|
||||
MalformedColor,
|
||||
}
|
||||
|
||||
#[derive(serde::Deserialize, Clone)]
|
||||
pub struct AccommodationRequest {
|
||||
pub name: String,
|
||||
pub need_validation: bool,
|
||||
pub description: Option<String>,
|
||||
pub color: Option<String>,
|
||||
pub open_to_reservations: bool,
|
||||
}
|
||||
|
||||
impl AccommodationRequest {
|
||||
pub async fn to_accommodation(self, accommodation: &mut Accommodation) -> anyhow::Result<()> {
|
||||
let c = StaticConstraints::default();
|
||||
|
||||
if !c.accommodation_name_len.validate(&self.name) {
|
||||
return Err(AccommodationListControllerErr::InvalidNameLength.into());
|
||||
}
|
||||
accommodation.name = self.name;
|
||||
|
||||
if let Some(d) = &self.description {
|
||||
if !c.accommodation_description_len.validate(d) {
|
||||
return Err(AccommodationListControllerErr::InvalidDescriptionLength.into());
|
||||
}
|
||||
}
|
||||
accommodation.description.clone_from(&self.description);
|
||||
|
||||
if let Some(c) = &self.color {
|
||||
if !lazy_regex::regex!("[a-fA-F0-9]{6}").is_match(c) {
|
||||
return Err(AccommodationListControllerErr::MalformedColor.into());
|
||||
}
|
||||
}
|
||||
accommodation.color.clone_from(&self.color);
|
||||
|
||||
accommodation.need_validation = self.need_validation;
|
||||
accommodation.open_to_reservations = self.open_to_reservations;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
/// Create a new accommodation
|
||||
pub async fn create(
|
||||
m: FamilyInPathWithAdminMembership,
|
||||
req: web::Json<AccommodationRequest>,
|
||||
) -> HttpResult {
|
||||
let mut accommodation = accommodations_list_service::create(m.family_id()).await?;
|
||||
|
||||
if let Err(e) = req.0.to_accommodation(&mut accommodation).await {
|
||||
log::error!("Failed to apply accommodation information! {e}");
|
||||
accommodations_list_service::delete(&mut accommodation).await?;
|
||||
return Ok(HttpResponse::BadRequest().body(e.to_string()));
|
||||
}
|
||||
|
||||
if let Err(e) = accommodations_list_service::update(&mut accommodation).await {
|
||||
log::error!("Failed to update accommodation information! {e}");
|
||||
accommodations_list_service::delete(&mut accommodation).await?;
|
||||
return Ok(HttpResponse::InternalServerError().finish());
|
||||
}
|
||||
|
||||
Ok(HttpResponse::Ok().json(accommodation))
|
||||
}
|
||||
|
||||
/// Get the full list of accommodations
|
||||
pub async fn get_full_list(m: FamilyInPath) -> HttpResult {
|
||||
Ok(HttpResponse::Ok()
|
||||
.json(accommodations_list_service::get_all_of_family(m.family_id()).await?))
|
||||
}
|
||||
|
||||
/// Get the information of a single accommodation
|
||||
pub async fn get_single(m: FamilyAndAccommodationInPath) -> HttpResult {
|
||||
Ok(HttpResponse::Ok().json(m.to_accommodation()))
|
||||
}
|
||||
|
||||
/// Update an accommodation
|
||||
pub async fn update(
|
||||
m: FamilyAndAccommodationInPath,
|
||||
req: web::Json<AccommodationRequest>,
|
||||
_admin: FamilyInPathWithAdminMembership,
|
||||
) -> HttpResult {
|
||||
let mut accommodation = m.to_accommodation();
|
||||
|
||||
if let Err(e) = req.0.to_accommodation(&mut accommodation).await {
|
||||
log::error!("Failed to parse accommodation information! {e}");
|
||||
return Ok(HttpResponse::BadRequest().body(e.to_string()));
|
||||
}
|
||||
|
||||
accommodations_list_service::update(&mut accommodation).await?;
|
||||
|
||||
Ok(HttpResponse::Accepted().finish())
|
||||
}
|
||||
|
||||
/// Delete an accommodation
|
||||
pub async fn delete(
|
||||
m: FamilyAndAccommodationInPath,
|
||||
_admin: FamilyInPathWithAdminMembership,
|
||||
) -> HttpResult {
|
||||
accommodations_list_service::delete(&mut m.to_accommodation()).await?;
|
||||
Ok(HttpResponse::Ok().finish())
|
||||
}
|
@ -0,0 +1,163 @@
|
||||
use ical::{generator::*, *};
|
||||
|
||||
use actix_web::{HttpResponse, web};
|
||||
use chrono::DateTime;
|
||||
|
||||
use crate::constants::StaticConstraints;
|
||||
use crate::controllers::HttpResult;
|
||||
use crate::extractors::accommodation_reservation_calendar_extractor::FamilyAndAccommodationReservationCalendarInPath;
|
||||
use crate::extractors::family_extractor::FamilyInPath;
|
||||
use crate::models::{AccommodationID, ReservationStatus};
|
||||
use crate::services::{
|
||||
accommodations_list_service, accommodations_reservations_calendars_service,
|
||||
accommodations_reservations_service, families_service,
|
||||
};
|
||||
use crate::utils::time_utils::time;
|
||||
|
||||
#[derive(serde::Deserialize)]
|
||||
pub struct CreateCalendarQuery {
|
||||
accommodation_id: Option<AccommodationID>,
|
||||
name: String,
|
||||
}
|
||||
|
||||
/// Create a calendar
|
||||
pub async fn create(a: FamilyInPath, req: web::Json<CreateCalendarQuery>) -> HttpResult {
|
||||
let accommodation_id = match req.accommodation_id {
|
||||
Some(i) => {
|
||||
let accommodation = match accommodations_list_service::get_by_id(i).await {
|
||||
Ok(a) => a,
|
||||
Err(e) => {
|
||||
log::error!("Failed to get accommodation information! {e}");
|
||||
return Ok(HttpResponse::NotFound()
|
||||
.json("The accommodation was not found in the family!"));
|
||||
}
|
||||
};
|
||||
|
||||
if accommodation.family_id() != a.family_id() {
|
||||
return Ok(
|
||||
HttpResponse::NotFound().json("The accommodation was not found in the family!")
|
||||
);
|
||||
}
|
||||
|
||||
Some(accommodation.id())
|
||||
}
|
||||
None => None,
|
||||
};
|
||||
|
||||
let conf = StaticConstraints::default();
|
||||
if !conf.accommodation_calendar_name_len.validate(&req.name) {
|
||||
return Ok(HttpResponse::BadRequest().json("Invalid accommodation name!"));
|
||||
}
|
||||
|
||||
let calendar = accommodations_reservations_calendars_service::create(
|
||||
a.user_id(),
|
||||
a.family_id(),
|
||||
accommodation_id,
|
||||
&req.name,
|
||||
)
|
||||
.await?;
|
||||
|
||||
Ok(HttpResponse::Ok().json(calendar))
|
||||
}
|
||||
|
||||
/// Get the list of calendars of a user
|
||||
pub async fn get_list(a: FamilyInPath) -> HttpResult {
|
||||
let users =
|
||||
accommodations_reservations_calendars_service::get_all_of_user(a.user_id(), a.family_id())
|
||||
.await?;
|
||||
Ok(HttpResponse::Ok().json(users))
|
||||
}
|
||||
|
||||
/// Delete a calendar
|
||||
pub async fn delete(resa: FamilyAndAccommodationReservationCalendarInPath) -> HttpResult {
|
||||
accommodations_reservations_calendars_service::delete(resa.to_reservation()).await?;
|
||||
Ok(HttpResponse::Ok().json("Calendar successfully deleted"))
|
||||
}
|
||||
|
||||
fn fmt_date(time: i64) -> String {
|
||||
let res = DateTime::from_timestamp(time, 0).expect("Failed to parse date");
|
||||
|
||||
/*format!(
|
||||
"{:0>4}{:0>2}{:0>2}T{:0>2}{:0>2}",
|
||||
res.year(),
|
||||
res.month(),
|
||||
res.day(),
|
||||
res.minute(),
|
||||
res.second()
|
||||
)*/
|
||||
|
||||
res.format("%Y%m%dT%H%M%S").to_string()
|
||||
}
|
||||
|
||||
#[derive(serde::Deserialize)]
|
||||
pub struct AnonymousAccessURL {
|
||||
token: String,
|
||||
}
|
||||
|
||||
/// Get the content of the calendar
|
||||
pub async fn anonymous_access(req: web::Path<AnonymousAccessURL>) -> HttpResult {
|
||||
let mut calendar =
|
||||
match accommodations_reservations_calendars_service::get_by_token(&req.token).await {
|
||||
Ok(c) => c,
|
||||
Err(e) => {
|
||||
log::error!("Calendar information could not be retrieved: {e}");
|
||||
return Ok(HttpResponse::NotFound().body("Calendar not found!"));
|
||||
}
|
||||
};
|
||||
|
||||
let accommodations =
|
||||
accommodations_list_service::get_all_of_family(calendar.family_id()).await?;
|
||||
let members = families_service::get_memberships_of_family(calendar.family_id()).await?;
|
||||
|
||||
// Get calendar associated events
|
||||
let events = match calendar.accommodation_id() {
|
||||
None => {
|
||||
accommodations_reservations_service::get_all_of_family(calendar.family_id()).await?
|
||||
}
|
||||
Some(a) => accommodations_reservations_service::get_all_of_accommodation(a).await?,
|
||||
};
|
||||
|
||||
let mut cal = IcalCalendarBuilder::version("2.0")
|
||||
.gregorian()
|
||||
.prodid("-//geneit//")
|
||||
.build();
|
||||
|
||||
for ev in events {
|
||||
let accommodation = accommodations
|
||||
.iter()
|
||||
.find(|a| a.id() == ev.accommodation_id())
|
||||
.unwrap();
|
||||
let member_name = members
|
||||
.iter()
|
||||
.find(|a| a.membership.user_id() == ev.user_id())
|
||||
.map(|m| m.user_name.as_str())
|
||||
.unwrap_or("other user");
|
||||
|
||||
let event = IcalEventBuilder::tzid("Europe/Paris")
|
||||
.uid(format!("resa-{}", ev.id().0))
|
||||
.changed(fmt_date(ev.time_update))
|
||||
.start(fmt_date(ev.reservation_start))
|
||||
.end(fmt_date(ev.reservation_end))
|
||||
.set(ical_property!("SUMMARY", member_name))
|
||||
.set(ical_property!("LOCATION", &accommodation.name))
|
||||
.set(ical_property!(
|
||||
"STATUS",
|
||||
match ev.status() {
|
||||
ReservationStatus::Pending => "TENTATIVE",
|
||||
ReservationStatus::Accepted => "CONFIRMED",
|
||||
ReservationStatus::Rejected => "CANCELLED",
|
||||
}
|
||||
))
|
||||
.build();
|
||||
cal.events.push(event);
|
||||
}
|
||||
|
||||
if calendar.should_update_last_used() {
|
||||
calendar.time_used = time() as i64;
|
||||
accommodations_reservations_calendars_service::update(&calendar).await?;
|
||||
}
|
||||
|
||||
Ok(HttpResponse::Ok()
|
||||
.content_type("text/calendar")
|
||||
.body(cal.generate()))
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user