diff --git a/decide/administration/frontend/src/components/02-molecules/Table/table.tsx b/decide/administration/frontend/src/components/02-molecules/Table/table.tsx
index 9d7d42e2ee..7ea2d95ae9 100644
--- a/decide/administration/frontend/src/components/02-molecules/Table/table.tsx
+++ b/decide/administration/frontend/src/components/02-molecules/Table/table.tsx
@@ -2,7 +2,15 @@ import * as React from "react";
import { DataGrid, GridColDef } from "@mui/x-data-grid";
-const Component = (props: { rows: any[]; columns: GridColDef[] }) => {
+const Component = (props: {
+ rows: any[];
+ columns: GridColDef[];
+ setSelected: any;
+}) => {
+ const filterRows = (ids: any[]) => {
+ return props.rows.filter((row: any) => ids.includes(row.id));
+ };
+
return (
{
rows={props.rows}
columns={props.columns}
checkboxSelection
+ onSelectionModelChange={(e) => props.setSelected(filterRows(e))}
/>
);
diff --git a/decide/administration/frontend/src/components/03-organisms/index.ts b/decide/administration/frontend/src/components/03-organisms/index.ts
index cb0ff5c3b5..7471c3f3f5 100644
--- a/decide/administration/frontend/src/components/03-organisms/index.ts
+++ b/decide/administration/frontend/src/components/03-organisms/index.ts
@@ -1 +1,3 @@
-export {};
+import { ActionBar } from "./Actions";
+
+export { ActionBar };
diff --git a/decide/administration/frontend/src/components/pages/page.tsx b/decide/administration/frontend/src/components/pages/page.tsx
index 4d1ffd8b6a..c974858d75 100644
--- a/decide/administration/frontend/src/components/pages/page.tsx
+++ b/decide/administration/frontend/src/components/pages/page.tsx
@@ -9,15 +9,12 @@ const Page = (props: {
}) => {
return (
<>
-
+
{props.children}
-
- {" "}
-
>
);
};
diff --git a/decide/administration/frontend/src/components/pages/users/users.tsx b/decide/administration/frontend/src/components/pages/users/users.tsx
index 8986da52b1..3d1d6dc5a5 100644
--- a/decide/administration/frontend/src/components/pages/users/users.tsx
+++ b/decide/administration/frontend/src/components/pages/users/users.tsx
@@ -1,8 +1,13 @@
import React from "react";
+import { Delete } from "@mui/icons-material";
+
+import { userApi } from "api";
+import { userType } from "types";
+
+import { ActionBar } from "components/03-organisms";
import { NewUserForm, UserTable } from "components/templates/users";
import Page from "../page";
-import { userApi } from "api";
// todo: fetch users from api and set rows to the response
const rows = [
@@ -19,6 +24,7 @@ const rows = [
const UsersPage = () => {
const [users, setUsers] = React.useState(rows);
+ const [selected, setSelected] = React.useState([]);
React.useEffect(() => {
userApi.getUsers().then((response) => {
@@ -27,11 +33,39 @@ const UsersPage = () => {
});
}, []);
+ const idList = React.useMemo(
+ () => selected.map((user: userType.User) => user.id),
+ [selected]
+ );
+
+ const handleDelete = () => {
+ console.log(idList);
+ };
+
return (
-
-
-
-
+ <>
+
+
+
+ ,
+ ]}
+ bulkActions={[
+ {
+ icon: ,
+ title: "Delete",
+ onClick: () => {
+ console.log("delete");
+ handleDelete();
+ },
+ },
+ ]}
+ />
+ >
);
};
diff --git a/decide/administration/frontend/src/components/templates/users/newUserForm.tsx b/decide/administration/frontend/src/components/templates/users/newUserForm.tsx
index 89b4192a6b..47058ebbfc 100644
--- a/decide/administration/frontend/src/components/templates/users/newUserForm.tsx
+++ b/decide/administration/frontend/src/components/templates/users/newUserForm.tsx
@@ -2,16 +2,18 @@ import React from "react";
import { SubmitHandler, useForm } from "react-hook-form";
import { userType } from "types";
import { ModalPage, Modal } from "components/02-molecules";
-import { Add } from "@mui/icons-material";
+import { Add, Edit } from "@mui/icons-material";
import { FormItem } from "components/01-atoms/Input";
-const Component = (props: { initialUser?: userType.User[] }) => {
+const Component = (props: { initialUser?: userType.User }) => {
const {
control,
getValues,
setError,
formState: { errors },
- } = useForm<{ username: string; username2: string }>();
+ } = useForm<{ username: string; username2: string }>({
+ defaultValues: { username: props.initialUser?.firstName || "" },
+ });
const [sent, setSent] = React.useState(false);
@@ -23,6 +25,8 @@ const Component = (props: { initialUser?: userType.User[] }) => {
const onSubmit: SubmitHandler<{ username: string; username2: string }> = (
data
) => {
+ //todo: if initialUser empty then call create new user
+ //todo: if initialUser is not empty, then call update
console.log("submit:", data);
//Todo: call api and create user,
//Todo: if created then close modal if not, call onSubmitFailed
@@ -35,7 +39,7 @@ const Component = (props: { initialUser?: userType.User[] }) => {
onSubmit(getValues())}
title="New User"
- openerIcon={}
+ openerIcon={props.initialUser ? : }
externalClose={sent}
pages={[
@@ -43,7 +47,7 @@ const Component = (props: { initialUser?: userType.User[] }) => {
control={control}
name="username"
error={errors.username?.message}
- >
+ />
,
]}
/>
diff --git a/decide/administration/frontend/src/components/templates/users/userTable.tsx b/decide/administration/frontend/src/components/templates/users/userTable.tsx
index dd7084c92b..a0cc21a80c 100644
--- a/decide/administration/frontend/src/components/templates/users/userTable.tsx
+++ b/decide/administration/frontend/src/components/templates/users/userTable.tsx
@@ -7,7 +7,6 @@ import { Table } from "components/02-molecules";
// todo: set correct columns
const columns: GridColDef[] = [
- { field: "id", headerName: "ID" },
{
field: "firstName",
headerName: "First name",
@@ -26,8 +25,14 @@ const columns: GridColDef[] = [
},
];
-const Component = (props: { users: userType.User[] }) => {
- return ;
+const Component = (props: { users: userType.User[]; setSelected: any }) => {
+ return (
+
+ );
};
export default Component;