diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml
index e18db9f..bfc35fd 100644
--- a/.idea/inspectionProfiles/Project_Default.xml
+++ b/.idea/inspectionProfiles/Project_Default.xml
@@ -6,11 +6,13 @@
+
+
diff --git a/frontend/package.json b/frontend/package.json
index dd66e35..ad3a972 100644
--- a/frontend/package.json
+++ b/frontend/package.json
@@ -8,7 +8,7 @@
"@fortawesome/free-solid-svg-icons": "^5.15.4",
"@fortawesome/react-fontawesome": "^0.1.15",
"@reach/router": "^1.3.4",
- "@steffo/bluelib-react": "^4.0.0",
+ "@steffo/bluelib-react": "^4.0.4",
"@testing-library/jest-dom": "^5.11.4",
"@testing-library/react": "^11.1.0",
"@testing-library/user-event": "^12.1.10",
diff --git a/frontend/src/components/group/GroupCreateBox.tsx b/frontend/src/components/group/GroupCreateBox.tsx
index fa9fc04..67d84ef 100644
--- a/frontend/src/components/group/GroupCreateBox.tsx
+++ b/frontend/src/components/group/GroupCreateBox.tsx
@@ -3,6 +3,7 @@ import * as React from "react"
import {useAuthorizationContext} from "../../contexts/authorization"
import {ManagedViewSet, useManagedViewSet} from "../../hooks/useManagedViewSet"
import {SophonResearchGroup, SophonUser} from "../../types/SophonTypes"
+import {ErrorBox} from "../errors/ErrorBox"
export interface GroupCreateBoxProps {
@@ -13,20 +14,51 @@ export interface GroupCreateBoxProps {
export function GroupCreateBox({viewSet}: GroupCreateBoxProps): JSX.Element | null {
const authorization = useAuthorizationContext()
- const name = useFormState("", val => val.length > 0 ? true : undefined)
+ const name =
+ useFormState("", val => val.length > 0 ? true : undefined)
+
+ const description =
+ useFormState("", val => val.length > 0 ? true : undefined)
+
+ const availableMembers =
+ useManagedViewSet("/api/core/users/", "id", authorization?.state.token !== undefined)
+
+ const membersOptions: { [key: string]: number } | undefined =
+ React.useMemo(
+ () => availableMembers.resources?.filter(m => m.value.id !== authorization?.state.user?.id).map(m => {
+ const obj: { [key: string]: number } = {}
+ obj[m.value.username] = m.value.id
+ return obj
+ }).reduce((a, b) => {
+ return {...a, ...b}
+ }),
+ [availableMembers, authorization],
+ )
+
+ const members =
+ useFormState([], arr => arr.length > 0 ? true : undefined)
+
+ const access =
+ useFormState<"OPEN" | "MANUAL" | undefined>(undefined, val => (
+ val?.length
+ ) ? true : undefined)
const slug = name.value.replaceAll(/[^A-Za-z0-9-]/g, "-").toLowerCase()
- const description = useFormState("", val => val.length > 0 ? true : undefined)
+ const doCreate =
+ React.useCallback(
+ async () => {
+ await viewSet.create({
+ name: name.value,
+ slug: slug,
+ description: description.value,
+ members: members.value,
+ access: access.value,
+ })
+ },
+ [viewSet, name, slug, description, members, access],
+ )
- const availableMembers = useManagedViewSet("/api/core/users/", "id", authorization?.state.token !== undefined)
- const membersOptions = React.useMemo(
- () => availableMembers.resources?.filter(m => m.value.id !== authorization?.state.user?.id).map(m => ),
- [availableMembers],
- )
- const members = useFormState([], arr => arr.length > 0 ? true : undefined)
-
- const access = useFormState("", val => val.length > 0 ? true : undefined)
if(!authorization?.state.token) {
return null
@@ -41,17 +73,22 @@ export function GroupCreateBox({viewSet}: GroupCreateBoxProps): JSX.Element | nu
0 ? true : undefined}/>
-
- {membersOptions}
-
-
-
-
-
-
-
+
+
+
-
+
+
+
+
Create
diff --git a/frontend/yarn.lock b/frontend/yarn.lock
index dd62506..542f60f 100644
--- a/frontend/yarn.lock
+++ b/frontend/yarn.lock
@@ -1617,10 +1617,10 @@
dependencies:
"@sinonjs/commons" "^1.7.0"
-"@steffo/bluelib-react@^4.0.0":
- version "4.0.0"
- resolved "https://registry.yarnpkg.com/@steffo/bluelib-react/-/bluelib-react-4.0.0.tgz#0956558e2fabac934a7e16ec8c1778f2dad414f0"
- integrity sha512-yymuz6Rt8nKlE3JScuMq5wB+FRAhUq2cRmcx8BBeg/MDfBWYwUlyxzzp8tPQrSrqctFsNewGydfeuiTNPi30Ug==
+"@steffo/bluelib-react@^4.0.4":
+ version "4.0.4"
+ resolved "https://registry.yarnpkg.com/@steffo/bluelib-react/-/bluelib-react-4.0.4.tgz#1a4f4ccd3ee185603a95b7a0a183a919f29e9d32"
+ integrity sha512-ZwnAqbZ4LaYbQu56fMX0OIKBJA1X4LUfTIJsxnkJbPrr2qX0D+zQUl2vI2Jm/wlZdltvwm5ftCTLDwpqg/1h/g==
dependencies:
"@babel/runtime" "^7.15.3"
classnames "^2.3.1"