From c03f637046de0c51698471ea35229aded2ea3f76 Mon Sep 17 00:00:00 2001 From: Yuze Fu Date: Sun, 21 Jul 2024 17:23:22 +0900 Subject: [PATCH] feat: add description to event and airspace --- Net.Vatprc.Uniapi.UI.Event/package.json | 11 +- Net.Vatprc.Uniapi.UI.Event/pnpm-lock.yaml | 198 ++++--- Net.Vatprc.Uniapi.UI.Event/src/api.d.ts | 6 + .../src/components/airspace-create.tsx | 84 ++- .../src/components/airspace-delete.tsx | 5 +- .../src/components/event-create.tsx | 24 +- .../src/components/event-detail.tsx | 2 + .../src/components/markdown.tsx | 15 + .../src/components/slot-detail.tsx | 74 ++- .../src/components/slot-import.tsx | 2 +- .../src/routes/events/$event_id.tsx | 3 + .../Controllers/EventAirspaceController.cs | 12 +- .../Controllers/EventController.cs | 6 + ...EventAndAirspaceAddDescription.Designer.cs | 538 ++++++++++++++++++ ...21074720_EventAndAirspaceAddDescription.cs | 40 ++ .../Migrations/VATPRCContextModelSnapshot.cs | 10 + Net.Vatprc.Uniapi/Models/Event.cs | 2 + Net.Vatprc.Uniapi/Models/EventAirspace.cs | 2 + 18 files changed, 906 insertions(+), 128 deletions(-) create mode 100644 Net.Vatprc.Uniapi.UI.Event/src/components/markdown.tsx create mode 100644 Net.Vatprc.Uniapi/Migrations/20240721074720_EventAndAirspaceAddDescription.Designer.cs create mode 100644 Net.Vatprc.Uniapi/Migrations/20240721074720_EventAndAirspaceAddDescription.cs diff --git a/Net.Vatprc.Uniapi.UI.Event/package.json b/Net.Vatprc.Uniapi.UI.Event/package.json index 06c7b8b..133efd0 100644 --- a/Net.Vatprc.Uniapi.UI.Event/package.json +++ b/Net.Vatprc.Uniapi.UI.Event/package.json @@ -16,11 +16,11 @@ "build-api": "openapi-typescript http://localhost:5000/api/swagger/v1/swagger.json -o src/api.d.ts && prettier --write src/api.d.ts" }, "dependencies": { - "@mantine/core": "^7.11.0", - "@mantine/dates": "^7.11.0", + "@mantine/core": "^7.11.2", + "@mantine/dates": "^7.11.2", "@mantine/dropzone": "^7.11.2", - "@mantine/hooks": "^7.11.0", - "@mantine/notifications": "^7.11.0", + "@mantine/hooks": "^7.11.2", + "@mantine/notifications": "^7.11.2", "@tabler/icons-react": "^3.10.0", "@tanstack/react-form": "^0.24.0", "@tanstack/react-query": "^5.48.0", @@ -28,7 +28,9 @@ "clsx": "^2.1.1", "date-fns": "^3.6.0", "date-fns-tz": "^3.1.3", + "dompurify": "^3.1.6", "jotai": "^2.7.0", + "marked": "^13.0.2", "openapi-fetch": "^0.10.2", "radash": "^12.1.0", "react": "^18.2.0", @@ -41,6 +43,7 @@ "@tanstack/router-devtools": "^1.40.0", "@tanstack/router-plugin": "^1.39.13", "@trivago/prettier-plugin-sort-imports": "^4.3.0", + "@types/dompurify": "^3.0.5", "@types/eslint__js": "^8.42.3", "@types/node": "^20.11.24", "@types/react": "^18.2.63", diff --git a/Net.Vatprc.Uniapi.UI.Event/pnpm-lock.yaml b/Net.Vatprc.Uniapi.UI.Event/pnpm-lock.yaml index e4a040e..e33bed1 100644 --- a/Net.Vatprc.Uniapi.UI.Event/pnpm-lock.yaml +++ b/Net.Vatprc.Uniapi.UI.Event/pnpm-lock.yaml @@ -9,20 +9,20 @@ importers: .: dependencies: '@mantine/core': - specifier: ^7.11.0 - version: 7.11.0(@mantine/hooks@7.11.0(react@18.2.0))(@types/react@18.2.63)(react-dom@18.2.0(react@18.2.0))(react@18.2.0) + specifier: ^7.11.2 + version: 7.11.2(@mantine/hooks@7.11.2(react@18.2.0))(@types/react@18.2.63)(react-dom@18.2.0(react@18.2.0))(react@18.2.0) '@mantine/dates': - specifier: ^7.11.0 - version: 7.11.0(@mantine/core@7.11.0(@mantine/hooks@7.11.0(react@18.2.0))(@types/react@18.2.63)(react-dom@18.2.0(react@18.2.0))(react@18.2.0))(@mantine/hooks@7.11.0(react@18.2.0))(dayjs@1.11.11)(react-dom@18.2.0(react@18.2.0))(react@18.2.0) + specifier: ^7.11.2 + version: 7.11.2(@mantine/core@7.11.2(@mantine/hooks@7.11.2(react@18.2.0))(@types/react@18.2.63)(react-dom@18.2.0(react@18.2.0))(react@18.2.0))(@mantine/hooks@7.11.2(react@18.2.0))(dayjs@1.11.12)(react-dom@18.2.0(react@18.2.0))(react@18.2.0) '@mantine/dropzone': specifier: ^7.11.2 - version: 7.11.2(@mantine/core@7.11.0(@mantine/hooks@7.11.0(react@18.2.0))(@types/react@18.2.63)(react-dom@18.2.0(react@18.2.0))(react@18.2.0))(@mantine/hooks@7.11.0(react@18.2.0))(react-dom@18.2.0(react@18.2.0))(react@18.2.0) + version: 7.11.2(@mantine/core@7.11.2(@mantine/hooks@7.11.2(react@18.2.0))(@types/react@18.2.63)(react-dom@18.2.0(react@18.2.0))(react@18.2.0))(@mantine/hooks@7.11.2(react@18.2.0))(react-dom@18.2.0(react@18.2.0))(react@18.2.0) '@mantine/hooks': - specifier: ^7.11.0 - version: 7.11.0(react@18.2.0) + specifier: ^7.11.2 + version: 7.11.2(react@18.2.0) '@mantine/notifications': - specifier: ^7.11.0 - version: 7.11.0(@mantine/core@7.11.0(@mantine/hooks@7.11.0(react@18.2.0))(@types/react@18.2.63)(react-dom@18.2.0(react@18.2.0))(react@18.2.0))(@mantine/hooks@7.11.0(react@18.2.0))(react-dom@18.2.0(react@18.2.0))(react@18.2.0) + specifier: ^7.11.2 + version: 7.11.2(@mantine/core@7.11.2(@mantine/hooks@7.11.2(react@18.2.0))(@types/react@18.2.63)(react-dom@18.2.0(react@18.2.0))(react@18.2.0))(@mantine/hooks@7.11.2(react@18.2.0))(react-dom@18.2.0(react@18.2.0))(react@18.2.0) '@tabler/icons-react': specifier: ^3.10.0 version: 3.10.0(react@18.2.0) @@ -44,9 +44,15 @@ importers: date-fns-tz: specifier: ^3.1.3 version: 3.1.3(date-fns@3.6.0) + dompurify: + specifier: ^3.1.6 + version: 3.1.6 jotai: specifier: ^2.7.0 version: 2.7.0(@types/react@18.2.63)(react@18.2.0) + marked: + specifier: ^13.0.2 + version: 13.0.2 openapi-fetch: specifier: ^0.10.2 version: 0.10.2 @@ -78,6 +84,9 @@ importers: '@trivago/prettier-plugin-sort-imports': specifier: ^4.3.0 version: 4.3.0(prettier@3.2.5) + '@types/dompurify': + specifier: ^3.0.5 + version: 3.0.5 '@types/eslint__js': specifier: ^8.42.3 version: 8.42.3 @@ -351,6 +360,10 @@ packages: resolution: {integrity: sha512-UwgBRMjJP+xv857DCngvqXI3Iq6J4v0wXmwc6sapg+zyhbwmQX67LUEFrkK5tbyJ30jGuG3ZvWpBiB9LCy1kWw==} engines: {node: '>=6.9.0'} + '@babel/runtime@7.24.8': + resolution: {integrity: sha512-5F7SDGs1T72ZczbRwbGO9lQi0NLjQxzl6i4lJxLxfW9U5UluCSyEJeniWvnhl3/euNiqQVbo8zruhsDfid0esA==} + engines: {node: '>=6.9.0'} + '@babel/template@7.22.15': resolution: {integrity: sha512-QPErUVm4uyJa60rkI73qneDacvdvzxshT3kksGqlGWYdOTIUOwJ7RDUL8sGqslY1uXWSL6xMFKEXDS3ox2uF0w==} engines: {node: '>=6.9.0'} @@ -555,11 +568,11 @@ packages: resolution: {integrity: sha512-A7+AOT2ICkodvtsWnxZP4Xxk3NbZ3VMHd8oihydLRGrJgqqdEz1qSeEgXYyT/Cu8h1TWWsQRejIx48mtjZ5y1w==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} - '@floating-ui/core@1.6.3': - resolution: {integrity: sha512-1ZpCvYf788/ZXOhRQGFxnYQOVgeU+pi0i+d0Ow34La7qjIXETi6RNswGVKkA6KcDO8/+Ysu2E/CeUmmeEBDvTg==} + '@floating-ui/core@1.6.4': + resolution: {integrity: sha512-a4IowK4QkXl4SCWTGUR0INAfEOX3wtsYw3rKK5InQEHMGObkR8Xk44qYQD9P4r6HHw0iIfK6GUKECmY8sTkqRA==} - '@floating-ui/dom@1.6.6': - resolution: {integrity: sha512-qiTYajAnh3P+38kECeffMSQgbvXty2VB6rS+42iWR4FPIlZjLK84E9qtLnMTLIpPz2znD/TaFqaiavMUrS+Hcw==} + '@floating-ui/dom@1.6.7': + resolution: {integrity: sha512-wmVfPG5o2xnKDU4jx/m4w5qva9FWHcnZ8BvzEe90D/RpwsJaTAVYPEPdQ8sbr/N8zZTAHlZUTQdqg8ZUbzHmng==} '@floating-ui/react-dom@2.1.1': resolution: {integrity: sha512-4h84MJt3CHrtG18mGsXuLCHMrug49d7DFkU0RMIyshRveBeyV2hmV/pDaF2Uxtu8kgq5r46llp5E5FQiR0K2Yg==} @@ -567,14 +580,14 @@ packages: react: '>=16.8.0' react-dom: '>=16.8.0' - '@floating-ui/react@0.26.18': - resolution: {integrity: sha512-enDDX09Jpi3kmhcXXpvs+fvRXOfBj1jUV2KF6uDMf5HjS+SOZJzNTFUW71lKbFcxz0BkmQqwbvqdmHIxMq/fyQ==} + '@floating-ui/react@0.26.19': + resolution: {integrity: sha512-Jk6zITdjjIvjO/VdQFvpRaD3qPwOHH6AoDHxjhpy+oK4KFgaSP871HYWUAPdnLmx1gQ+w/pB312co3tVml+BXA==} peerDependencies: react: '>=16.8.0' react-dom: '>=16.8.0' - '@floating-ui/utils@0.2.3': - resolution: {integrity: sha512-XGndio0l5/Gvd6CLIABvsav9HHezgDFFhDfHk1bvLfr9ni8dojqLSvBbotJEjmIwNHL7vK4QzBJTdBRoB+c1ww==} + '@floating-ui/utils@0.2.4': + resolution: {integrity: sha512-dWO2pw8hhi+WrXq1YJy2yCuWoL20PddgGaqTgVe4cOS9Q6qklXCiA1tJEqX6BEwRNSCP84/afac9hd4MS+zEUA==} '@humanwhocodes/config-array@0.11.14': resolution: {integrity: sha512-3T8LkOmg45BV5FICb15QQMsyUSWrQ8AygVfC7ZG32zOalnqrilm018ZVCw0eapXux8FtA33q8PSRSstjee3jSg==} @@ -620,18 +633,18 @@ packages: '@jridgewell/trace-mapping@0.3.25': resolution: {integrity: sha512-vNk6aEwybGtawWmy/PzwnGDOjCkLWSD2wqvjGGAgOAwCGWySYXfYoxt00IJkTF+8Lb57DwOb3Aa0o9CApepiYQ==} - '@mantine/core@7.11.0': - resolution: {integrity: sha512-yw2Llww9mw8rDWZtucdEuvkqqjHdreUibos7JCUpejL721FW1Tn9L91nsxO/YQFSS7jn4Q0CP+1YbQ/PMULmwA==} + '@mantine/core@7.11.2': + resolution: {integrity: sha512-T64RjdgY8UPAv249miW1lQyPPot1JbCcKKsAZMNQHgcttcxLhrFpKVvglc4/48hdSoxI4LYJPNvqp7zciZmucQ==} peerDependencies: - '@mantine/hooks': 7.11.0 + '@mantine/hooks': 7.11.2 react: ^18.2.0 react-dom: ^18.2.0 - '@mantine/dates@7.11.0': - resolution: {integrity: sha512-4wKzOyOvDDh8/TV1SYGHDWydflweRiem4cJt3S49LO1Forpy2SiJ18Gn4ylGiqZdWxz1HY4Jb5kl7GAzxLD4tQ==} + '@mantine/dates@7.11.2': + resolution: {integrity: sha512-BEZs949EvfIG1fRNsEpcB0YqSe53z/KObwHyBwiqFjFHJ2eFPVMpxw6Rpy1Bud0/FZRV+QBokebxaf6+2tbCCw==} peerDependencies: - '@mantine/core': 7.11.0 - '@mantine/hooks': 7.11.0 + '@mantine/core': 7.11.2 + '@mantine/hooks': 7.11.2 dayjs: '>=1.0.0' react: ^18.2.0 react-dom: ^18.2.0 @@ -644,21 +657,21 @@ packages: react: ^18.2.0 react-dom: ^18.2.0 - '@mantine/hooks@7.11.0': - resolution: {integrity: sha512-T3472GhUXFhuhXUHlxjHv0wfb73lFyNuaw631c7Ddtgvewq0WKtNqYd7j/Zz/k02DuS3r0QXA7e12/XgqHBZjg==} + '@mantine/hooks@7.11.2': + resolution: {integrity: sha512-jhyVe/sbDEG2U8rr2lMecUPgQxcfr5hh9HazqGfkS7ZRIMDO7uJ947yAcTMGGkp5Lxtt5TBFt1Cb6tiB2/1agg==} peerDependencies: react: ^18.2.0 - '@mantine/notifications@7.11.0': - resolution: {integrity: sha512-UtAHJoSi4s+lfVZrkUDWMlg6j0w1LZaiMEOBMG9p5MV5dP38W75LeCy2cio2Znji2S5YzXaZolOkHBT5ZONKAw==} + '@mantine/notifications@7.11.2': + resolution: {integrity: sha512-KB/6mp3mU3LvcFlfMc5zK5mWcrAO+zAGeiBb1oUjNFXBECCn9xizqqUeT0YbWBHL7wysq9IThDJxLwUBnQt+8Q==} peerDependencies: - '@mantine/core': 7.11.0 - '@mantine/hooks': 7.11.0 + '@mantine/core': 7.11.2 + '@mantine/hooks': 7.11.2 react: ^18.2.0 react-dom: ^18.2.0 - '@mantine/store@7.11.0': - resolution: {integrity: sha512-zPmOpdFgvkUqYKSK7NNKbhgXsh2QPw51m3iypTaj0mw+rZbk3WSH9vZvaEx59X0QG+ahwUg2/HezbjfXFUbvrA==} + '@mantine/store@7.11.2': + resolution: {integrity: sha512-FfkmnOnCivOjqwNaTZeV4TgDANUs7fP+0uSgzp0GuvwTuDfQNVafPBRzPkjKuz5ug+Nn9l6WwjfJ6LBDv9U0LQ==} peerDependencies: react: ^18.2.0 @@ -850,6 +863,9 @@ packages: '@types/babel__traverse@7.20.6': resolution: {integrity: sha512-r1bzfrm0tomOI8g1SzvCaQHo6Lcv6zu0EA+W2kHrt8dyrHQxGzBBL4kdkzIS+jBMV+EYcMAEAqXqYaLJq5rOZg==} + '@types/dompurify@3.0.5': + resolution: {integrity: sha512-1Wg0g3BtQF7sSb27fJQAKck1HECM6zV1EB66j8JH9i3LCjYabJa0FSdiSgsD5K/RbrsR0SiraKacLB+T8ZVYAg==} + '@types/eslint@8.56.10': resolution: {integrity: sha512-Shavhk87gCtY2fhXDctcfS3e6FdxWkCx1iUZ9eEUbh7rTqlZT0/IzOkCOVt0fCjcFuZ9FPYfuezTBImfHCDBGQ==} @@ -877,6 +893,9 @@ packages: '@types/scheduler@0.16.8': resolution: {integrity: sha512-WZLiwShhwLRmeV6zH+GkbOFT6Z6VklCItrDioxUnv+u4Ll+8vKeFySoFyK/0ctcRpOmwAicELfmys1sDc/Rw+A==} + '@types/trusted-types@2.0.7': + resolution: {integrity: sha512-ScaPdn1dQczgbl0QFTeTOmVHFULt394XJgOQNoyVhZ6r2vLnMLJfBPd53SB52T/3G36VI1/g2MZaX0cwDuXsfw==} + '@typescript-eslint/eslint-plugin@7.16.0': resolution: {integrity: sha512-py1miT6iQpJcs1BiJjm54AMzeuMPBSPuKPlnT8HlfudbcS5rYeX5jajpLf3mrdRh9dA/Ec2FVUY0ifeVNDIhZw==} engines: {node: ^18.18.0 || >=20.0.0} @@ -1133,8 +1152,8 @@ packages: date-fns@3.6.0: resolution: {integrity: sha512-fRHTG8g/Gif+kSh50gaGEdToemgfj74aRX3swtiouboip5JDLAyDE9F11nHMIcvOaXeOC6D7SpNhi7uFyB7Uww==} - dayjs@1.11.11: - resolution: {integrity: sha512-okzr3f11N6WuqYtZSvm+F776mB41wRZMhKP+hc34YdW+KmtYYK9iqvHSwo2k9FEH3fhGXvOPV6yz2IcSrfRUDg==} + dayjs@1.11.12: + resolution: {integrity: sha512-Rt2g+nTbLlDWZTwwrIXjy9MeiZmSDI375FvZs72ngxx8PDC6YXOeR3q5LAuPzjZQxhiWdRKac7RKV+YyQYfYIg==} debug@4.3.4: resolution: {integrity: sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==} @@ -1186,6 +1205,9 @@ packages: dom-helpers@5.2.1: resolution: {integrity: sha512-nRCa7CK3VTrM2NmGkIy4cbK7IZlgBE/PYMn55rrXefr5xXDP0LdtfPnblFDoVdcAfslJ7or6iqAUnx0CCGIWQA==} + dompurify@3.1.6: + resolution: {integrity: sha512-cTOAhc36AalkjtBpfG6O8JimdTMWNXjiePT2xQH/ppBGi/4uIpmj8eKyIkMJErXWARyINV/sB38yf8JCLF5pbQ==} + electron-to-chromium@1.4.693: resolution: {integrity: sha512-/if4Ueg0GUQlhCrW2ZlXwDAm40ipuKo+OgeHInlL8sbjt+hzISxZK949fZeJaVsheamrzANXvw1zQTvbxTvSHw==} @@ -1656,6 +1678,11 @@ packages: lru-cache@5.1.1: resolution: {integrity: sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==} + marked@13.0.2: + resolution: {integrity: sha512-J6CPjP8pS5sgrRqxVRvkCIkZ6MFdRIjDkwUwgJ9nL2fbmM6qGQeB2C16hi8Cc9BOzj6xXzy0jyi0iPIfnMHYzA==} + engines: {node: '>= 18'} + hasBin: true + merge2@1.4.1: resolution: {integrity: sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==} engines: {node: '>= 8'} @@ -1895,8 +1922,8 @@ packages: '@types/react': optional: true - react-remove-scroll@2.5.7: - resolution: {integrity: sha512-FnrTWO4L7/Bhhf3CYBNArEG/yROV0tKmTv7/3h9QCFvH6sndeFf1wPqOcbFVu5VAulS5dV1wGT3GZZ/1GawqiA==} + react-remove-scroll@2.5.10: + resolution: {integrity: sha512-m3zvBRANPBw3qxVVjEIPEQinkcwlFZ4qyomuWVpNJdv4c6MvHfXV0C3L9Jx5rr3HeBHKNRX+1jreB5QloDIJjA==} engines: {node: '>=10'} peerDependencies: '@types/react': ^16.8.0 || ^17.0.0 || ^18.0.0 @@ -2129,6 +2156,9 @@ packages: tslib@2.6.2: resolution: {integrity: sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==} + tslib@2.6.3: + resolution: {integrity: sha512-xNvxJEOUiWPGhUuUdQgAJPKOOJfGnIyKySOc09XkKsgdUV/3E2zvwZYdejjmRgPCgcym1juLH3226yA7sEFJKQ==} + type-check@0.4.0: resolution: {integrity: sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==} engines: {node: '>= 0.8.0'} @@ -2141,6 +2171,10 @@ packages: resolution: {integrity: sha512-R6wDsVsoS9xYOpy8vgeBlqpdOyzJ12HNfQhC/aAKWM3YoCV9TtunJzh/QpkMgeDhkoynDcw5f1y+qF9yc/HHyg==} engines: {node: '>=16'} + type-fest@4.22.1: + resolution: {integrity: sha512-9tHNEa0Ov81YOopiVkcCJVz5TM6AEQ+CHHjFIktqPnE3NV0AHIkx+gh9tiCl58m/66wWxkOC9eltpa75J4lQPA==} + engines: {node: '>=16'} + typed-array-buffer@1.0.2: resolution: {integrity: sha512-gEymJYKZtKXzzBzM4jqa9w6Q1Jjm7x2d+sh19AdsD4wqnMPDYyvwpsIc2Q/835kHuo3BEQ7CjelGhfTsoBb2MQ==} engines: {node: '>= 0.4'} @@ -2597,6 +2631,10 @@ snapshots: dependencies: regenerator-runtime: 0.14.1 + '@babel/runtime@7.24.8': + dependencies: + regenerator-runtime: 0.14.1 + '@babel/template@7.22.15': dependencies: '@babel/code-frame': 7.23.5 @@ -2779,30 +2817,30 @@ snapshots: '@eslint/js@9.5.0': {} - '@floating-ui/core@1.6.3': + '@floating-ui/core@1.6.4': dependencies: - '@floating-ui/utils': 0.2.3 + '@floating-ui/utils': 0.2.4 - '@floating-ui/dom@1.6.6': + '@floating-ui/dom@1.6.7': dependencies: - '@floating-ui/core': 1.6.3 - '@floating-ui/utils': 0.2.3 + '@floating-ui/core': 1.6.4 + '@floating-ui/utils': 0.2.4 '@floating-ui/react-dom@2.1.1(react-dom@18.2.0(react@18.2.0))(react@18.2.0)': dependencies: - '@floating-ui/dom': 1.6.6 + '@floating-ui/dom': 1.6.7 react: 18.2.0 react-dom: 18.2.0(react@18.2.0) - '@floating-ui/react@0.26.18(react-dom@18.2.0(react@18.2.0))(react@18.2.0)': + '@floating-ui/react@0.26.19(react-dom@18.2.0(react@18.2.0))(react@18.2.0)': dependencies: '@floating-ui/react-dom': 2.1.1(react-dom@18.2.0(react@18.2.0))(react@18.2.0) - '@floating-ui/utils': 0.2.3 + '@floating-ui/utils': 0.2.4 react: 18.2.0 react-dom: 18.2.0(react@18.2.0) tabbable: 6.2.0 - '@floating-ui/utils@0.2.3': {} + '@floating-ui/utils@0.2.4': {} '@humanwhocodes/config-array@0.11.14': dependencies: @@ -2848,51 +2886,51 @@ snapshots: '@jridgewell/resolve-uri': 3.1.2 '@jridgewell/sourcemap-codec': 1.4.15 - '@mantine/core@7.11.0(@mantine/hooks@7.11.0(react@18.2.0))(@types/react@18.2.63)(react-dom@18.2.0(react@18.2.0))(react@18.2.0)': + '@mantine/core@7.11.2(@mantine/hooks@7.11.2(react@18.2.0))(@types/react@18.2.63)(react-dom@18.2.0(react@18.2.0))(react@18.2.0)': dependencies: - '@floating-ui/react': 0.26.18(react-dom@18.2.0(react@18.2.0))(react@18.2.0) - '@mantine/hooks': 7.11.0(react@18.2.0) + '@floating-ui/react': 0.26.19(react-dom@18.2.0(react@18.2.0))(react@18.2.0) + '@mantine/hooks': 7.11.2(react@18.2.0) clsx: 2.1.1 react: 18.2.0 react-dom: 18.2.0(react@18.2.0) react-number-format: 5.4.0(react-dom@18.2.0(react@18.2.0))(react@18.2.0) - react-remove-scroll: 2.5.7(@types/react@18.2.63)(react@18.2.0) + react-remove-scroll: 2.5.10(@types/react@18.2.63)(react@18.2.0) react-textarea-autosize: 8.5.3(@types/react@18.2.63)(react@18.2.0) - type-fest: 4.20.1 + type-fest: 4.22.1 transitivePeerDependencies: - '@types/react' - '@mantine/dates@7.11.0(@mantine/core@7.11.0(@mantine/hooks@7.11.0(react@18.2.0))(@types/react@18.2.63)(react-dom@18.2.0(react@18.2.0))(react@18.2.0))(@mantine/hooks@7.11.0(react@18.2.0))(dayjs@1.11.11)(react-dom@18.2.0(react@18.2.0))(react@18.2.0)': + '@mantine/dates@7.11.2(@mantine/core@7.11.2(@mantine/hooks@7.11.2(react@18.2.0))(@types/react@18.2.63)(react-dom@18.2.0(react@18.2.0))(react@18.2.0))(@mantine/hooks@7.11.2(react@18.2.0))(dayjs@1.11.12)(react-dom@18.2.0(react@18.2.0))(react@18.2.0)': dependencies: - '@mantine/core': 7.11.0(@mantine/hooks@7.11.0(react@18.2.0))(@types/react@18.2.63)(react-dom@18.2.0(react@18.2.0))(react@18.2.0) - '@mantine/hooks': 7.11.0(react@18.2.0) + '@mantine/core': 7.11.2(@mantine/hooks@7.11.2(react@18.2.0))(@types/react@18.2.63)(react-dom@18.2.0(react@18.2.0))(react@18.2.0) + '@mantine/hooks': 7.11.2(react@18.2.0) clsx: 2.1.1 - dayjs: 1.11.11 + dayjs: 1.11.12 react: 18.2.0 react-dom: 18.2.0(react@18.2.0) - '@mantine/dropzone@7.11.2(@mantine/core@7.11.0(@mantine/hooks@7.11.0(react@18.2.0))(@types/react@18.2.63)(react-dom@18.2.0(react@18.2.0))(react@18.2.0))(@mantine/hooks@7.11.0(react@18.2.0))(react-dom@18.2.0(react@18.2.0))(react@18.2.0)': + '@mantine/dropzone@7.11.2(@mantine/core@7.11.2(@mantine/hooks@7.11.2(react@18.2.0))(@types/react@18.2.63)(react-dom@18.2.0(react@18.2.0))(react@18.2.0))(@mantine/hooks@7.11.2(react@18.2.0))(react-dom@18.2.0(react@18.2.0))(react@18.2.0)': dependencies: - '@mantine/core': 7.11.0(@mantine/hooks@7.11.0(react@18.2.0))(@types/react@18.2.63)(react-dom@18.2.0(react@18.2.0))(react@18.2.0) - '@mantine/hooks': 7.11.0(react@18.2.0) + '@mantine/core': 7.11.2(@mantine/hooks@7.11.2(react@18.2.0))(@types/react@18.2.63)(react-dom@18.2.0(react@18.2.0))(react@18.2.0) + '@mantine/hooks': 7.11.2(react@18.2.0) react: 18.2.0 react-dom: 18.2.0(react@18.2.0) react-dropzone-esm: 15.0.1(react@18.2.0) - '@mantine/hooks@7.11.0(react@18.2.0)': + '@mantine/hooks@7.11.2(react@18.2.0)': dependencies: react: 18.2.0 - '@mantine/notifications@7.11.0(@mantine/core@7.11.0(@mantine/hooks@7.11.0(react@18.2.0))(@types/react@18.2.63)(react-dom@18.2.0(react@18.2.0))(react@18.2.0))(@mantine/hooks@7.11.0(react@18.2.0))(react-dom@18.2.0(react@18.2.0))(react@18.2.0)': + '@mantine/notifications@7.11.2(@mantine/core@7.11.2(@mantine/hooks@7.11.2(react@18.2.0))(@types/react@18.2.63)(react-dom@18.2.0(react@18.2.0))(react@18.2.0))(@mantine/hooks@7.11.2(react@18.2.0))(react-dom@18.2.0(react@18.2.0))(react@18.2.0)': dependencies: - '@mantine/core': 7.11.0(@mantine/hooks@7.11.0(react@18.2.0))(@types/react@18.2.63)(react-dom@18.2.0(react@18.2.0))(react@18.2.0) - '@mantine/hooks': 7.11.0(react@18.2.0) - '@mantine/store': 7.11.0(react@18.2.0) + '@mantine/core': 7.11.2(@mantine/hooks@7.11.2(react@18.2.0))(@types/react@18.2.63)(react-dom@18.2.0(react@18.2.0))(react@18.2.0) + '@mantine/hooks': 7.11.2(react@18.2.0) + '@mantine/store': 7.11.2(react@18.2.0) react: 18.2.0 react-dom: 18.2.0(react@18.2.0) react-transition-group: 4.4.5(react-dom@18.2.0(react@18.2.0))(react@18.2.0) - '@mantine/store@7.11.0(react@18.2.0)': + '@mantine/store@7.11.2(react@18.2.0)': dependencies: react: 18.2.0 @@ -3105,6 +3143,10 @@ snapshots: dependencies: '@babel/types': 7.24.7 + '@types/dompurify@3.0.5': + dependencies: + '@types/trusted-types': 2.0.7 + '@types/eslint@8.56.10': dependencies: '@types/estree': 1.0.5 @@ -3136,6 +3178,8 @@ snapshots: '@types/scheduler@0.16.8': {} + '@types/trusted-types@2.0.7': {} + '@typescript-eslint/eslint-plugin@7.16.0(@typescript-eslint/parser@7.16.0(eslint@8.57.0)(typescript@5.5.3))(eslint@8.57.0)(typescript@5.5.3)': dependencies: '@eslint-community/regexpp': 4.11.0 @@ -3458,7 +3502,7 @@ snapshots: date-fns@3.6.0: {} - dayjs@1.11.11: {} + dayjs@1.11.12: {} debug@4.3.4(supports-color@9.4.0): dependencies: @@ -3502,9 +3546,11 @@ snapshots: dom-helpers@5.2.1: dependencies: - '@babel/runtime': 7.24.7 + '@babel/runtime': 7.24.8 csstype: 3.1.3 + dompurify@3.1.6: {} + electron-to-chromium@1.4.693: {} emoji-regex@8.0.0: {} @@ -4074,6 +4120,8 @@ snapshots: dependencies: yallist: 3.1.1 + marked@13.0.2: {} + merge2@1.4.1: {} micromatch@4.0.5: @@ -4289,16 +4337,16 @@ snapshots: dependencies: react: 18.2.0 react-style-singleton: 2.2.1(@types/react@18.2.63)(react@18.2.0) - tslib: 2.6.2 + tslib: 2.6.3 optionalDependencies: '@types/react': 18.2.63 - react-remove-scroll@2.5.7(@types/react@18.2.63)(react@18.2.0): + react-remove-scroll@2.5.10(@types/react@18.2.63)(react@18.2.0): dependencies: react: 18.2.0 react-remove-scroll-bar: 2.3.6(@types/react@18.2.63)(react@18.2.0) react-style-singleton: 2.2.1(@types/react@18.2.63)(react@18.2.0) - tslib: 2.6.2 + tslib: 2.6.3 use-callback-ref: 1.3.2(@types/react@18.2.63)(react@18.2.0) use-sidecar: 1.1.2(@types/react@18.2.63)(react@18.2.0) optionalDependencies: @@ -4309,13 +4357,13 @@ snapshots: get-nonce: 1.0.1 invariant: 2.2.4 react: 18.2.0 - tslib: 2.6.2 + tslib: 2.6.3 optionalDependencies: '@types/react': 18.2.63 react-textarea-autosize@8.5.3(@types/react@18.2.63)(react@18.2.0): dependencies: - '@babel/runtime': 7.24.7 + '@babel/runtime': 7.24.8 react: 18.2.0 use-composed-ref: 1.3.0(react@18.2.0) use-latest: 1.2.1(@types/react@18.2.63)(react@18.2.0) @@ -4324,7 +4372,7 @@ snapshots: react-transition-group@4.4.5(react-dom@18.2.0(react@18.2.0))(react@18.2.0): dependencies: - '@babel/runtime': 7.24.7 + '@babel/runtime': 7.24.8 dom-helpers: 5.2.1 loose-envify: 1.4.0 prop-types: 15.8.1 @@ -4553,6 +4601,8 @@ snapshots: tslib@2.6.2: {} + tslib@2.6.3: {} + type-check@0.4.0: dependencies: prelude-ls: 1.2.1 @@ -4561,6 +4611,8 @@ snapshots: type-fest@4.20.1: {} + type-fest@4.22.1: {} + typed-array-buffer@1.0.2: dependencies: call-bind: 1.0.7 @@ -4635,7 +4687,7 @@ snapshots: use-callback-ref@1.3.2(@types/react@18.2.63)(react@18.2.0): dependencies: react: 18.2.0 - tslib: 2.6.2 + tslib: 2.6.3 optionalDependencies: '@types/react': 18.2.63 @@ -4660,7 +4712,7 @@ snapshots: dependencies: detect-node-es: 1.1.0 react: 18.2.0 - tslib: 2.6.2 + tslib: 2.6.3 optionalDependencies: '@types/react': 18.2.63 diff --git a/Net.Vatprc.Uniapi.UI.Event/src/api.d.ts b/Net.Vatprc.Uniapi.UI.Event/src/api.d.ts index 35f3e19..5be3b8e 100644 --- a/Net.Vatprc.Uniapi.UI.Event/src/api.d.ts +++ b/Net.Vatprc.Uniapi.UI.Event/src/api.d.ts @@ -292,6 +292,7 @@ export interface components { CreateEventAirspaceDto: { name: string; icao_codes: string[]; + description: string; }; CreateEventDto: { title: string; @@ -304,6 +305,7 @@ export interface components { /** Format: date-time */ end_booking_at: string; image_url?: string | null; + description: string; }; CreateEventSlotDto: { airspace_id: string; @@ -326,6 +328,7 @@ export interface components { /** Format: date-time */ updated_at: string; icao_codes: string[]; + description: string; }; EventBookingDto: { id: string; @@ -351,6 +354,7 @@ export interface components { /** Format: date-time */ end_booking_at: string; image_url?: string | null; + description: string; }; EventSlotDto: { id: string; @@ -399,6 +403,7 @@ export interface components { UpdateEventAirspaceDto: { name: string; icao_codes: string[]; + description: string; }; UpdateEventDto: { title: string; @@ -411,6 +416,7 @@ export interface components { /** Format: date-time */ end_booking_at: string; image_url?: string | null; + description: string; }; UpdateEventSlotDto: { /** Format: date-time */ diff --git a/Net.Vatprc.Uniapi.UI.Event/src/components/airspace-create.tsx b/Net.Vatprc.Uniapi.UI.Event/src/components/airspace-create.tsx index 5c3b4fe..667d4c4 100644 --- a/Net.Vatprc.Uniapi.UI.Event/src/components/airspace-create.tsx +++ b/Net.Vatprc.Uniapi.UI.Event/src/components/airspace-create.tsx @@ -1,32 +1,70 @@ -import { useApiPost } from "@/client"; +import { invalidatePath, useApi, useApiPost, useApiPut } from "@/client"; import { useUser } from "@/services/auth"; import { promiseWithToast } from "@/utils"; -import { ActionIcon, Button, MantineSpacing, Modal, Stack, StyleProp, TagsInput, TextInput } from "@mantine/core"; +import { + ActionIcon, + Button, + MantineSpacing, + Modal, + Stack, + StyleProp, + TagsInput, + TextInput, + Textarea, +} from "@mantine/core"; import { useDisclosure } from "@mantine/hooks"; -import { IconPlus } from "@tabler/icons-react"; +import { IconEdit, IconPlus } from "@tabler/icons-react"; import { useForm } from "@tanstack/react-form"; -export const CreateAirspace = ({ ml, eventId }: { ml?: StyleProp; eventId: string }) => { +const NULL_ULID = "01J2N4V2BNSP3E5Q9MBA3AE8E3"; +export const CreateAirspace = ({ + ml, + eventId, + airspaceId, +}: { + ml?: StyleProp; + eventId: string; + airspaceId?: string; +}) => { + const [opened, { toggle, close }] = useDisclosure(false); + const user = useUser(); - const { mutate } = useApiPost("/api/events/{eid}/airspaces", { path: { eid: eventId } }, () => close()); + const { data: airspace, isLoading } = useApi(`/api/events/{eid}/airspaces/{aid}`, { + path: { eid: eventId, aid: airspaceId ?? NULL_ULID }, + enabled: !!airspaceId && opened, + }); + const onComplete = () => { + close(); + return invalidatePath(`/api/events/{eid}/airspaces`, { eid: eventId }); + }; + const { mutate: create, isPending: isCreatePending } = useApiPost( + "/api/events/{eid}/airspaces", + { path: { eid: eventId } }, + onComplete, + ); + const { mutate: update, isPending: isUpdatePending } = useApiPut( + "/api/events/{eid}/airspaces/{aid}", + { path: { eid: eventId, aid: airspaceId ?? NULL_ULID } }, + onComplete, + ); const form = useForm({ defaultValues: { - name: "", - icaoCodes: [] as string[], + name: airspace?.name ?? "", + icao_codes: airspace?.icao_codes ?? ([] as string[]), + description: airspace?.description ?? "", }, onSubmit: ({ value }) => { - mutate({ name: value.name, icao_codes: value.icaoCodes }); + if (airspaceId) return update(value); + else return create(value); }, }); - const [opened, { toggle, close }] = useDisclosure(false); - if (!user.roles.includes("ec")) return null; return ( <> - + {airspaceId ? : }
onChange={(e) => field.handleChange(e.target.value)} value={field.state.value} onBlur={field.handleBlur} - > + disabled={isLoading} + /> )} /> ( field.handleChange(e)} value={field.state.value} onBlur={field.handleBlur} - > + disabled={isLoading} + /> )} /> -