diff --git a/client/src/App.tsx b/client/src/App.tsx
index 40cb170..a4d3f4d 100644
--- a/client/src/App.tsx
+++ b/client/src/App.tsx
@@ -3,6 +3,9 @@ import dataProvider from "./dataProvider";
import RolesList from "./components/Role/List";
import RoleCreate from "./components/Role/Create";
import RoleEdit from "./components/Role/Edit";
+import UsersList from "./components/User/List";
+import UserCreate from "./components/User/Create";
+import UserEdit from "./components/User/Edit";
function App() {
return (
@@ -13,6 +16,12 @@ function App() {
create={}
edit={}
/>
+ }
+ create={}
+ edit={}
+ />
);
}
diff --git a/client/src/components/User/Create.tsx b/client/src/components/User/Create.tsx
new file mode 100644
index 0000000..0dfe04b
--- /dev/null
+++ b/client/src/components/User/Create.tsx
@@ -0,0 +1,27 @@
+import {
+ Create,
+ PasswordInput,
+ ReferenceInput,
+ SelectInput,
+ SimpleForm,
+ TextInput,
+ required,
+} from "react-admin";
+
+function UserCreate() {
+ return (
+
+
+
+
+
+
+
+
+
+
+
+ );
+}
+
+export default UserCreate;
diff --git a/client/src/components/User/Edit.tsx b/client/src/components/User/Edit.tsx
new file mode 100644
index 0000000..1894588
--- /dev/null
+++ b/client/src/components/User/Edit.tsx
@@ -0,0 +1,28 @@
+import {
+ Edit,
+ PasswordInput,
+ ReferenceInput,
+ SelectInput,
+ SimpleForm,
+ TextInput,
+ required,
+} from "react-admin";
+import Title from "../Title";
+
+function UserEdit() {
+ return (
+ } actions={false}>
+
+
+
+
+
+
+
+
+
+
+ );
+}
+
+export default UserEdit;
diff --git a/client/src/components/User/List.tsx b/client/src/components/User/List.tsx
new file mode 100644
index 0000000..2f23bf9
--- /dev/null
+++ b/client/src/components/User/List.tsx
@@ -0,0 +1,17 @@
+import { List, Datagrid, TextField, EditButton } from "react-admin";
+
+function UsersList() {
+ return (
+
+
+
+
+
+
+
+
+
+ );
+};
+
+export default UsersList;
\ No newline at end of file
diff --git a/server/.eslintrc b/server/.eslintrc
new file mode 100644
index 0000000..b4db045
--- /dev/null
+++ b/server/.eslintrc
@@ -0,0 +1,34 @@
+{
+ "env": { "browser": true, "es2020": true },
+ "extends": [
+ "eslint:recommended",
+ "plugin:@typescript-eslint/recommended",
+ "plugin:prettier/recommended"
+ ],
+ "parser": "@typescript-eslint/parser",
+ "parserOptions": { "ecmaVersion": "latest", "sourceType": "module" },
+ "plugins": ["import"],
+ "rules": {
+ "@typescript-eslint/consistent-type-imports": "error",
+ "prettier/prettier": ["warn", { "endOfLine": "auto" }],
+ "no-console": "warn",
+ "prefer-const": "error",
+ "comma-dangle": ["warn", "never"],
+ "semi": ["warn", "always"],
+ "import/order": [
+ "warn",
+ {
+ "groups": [
+ "builtin",
+ "external",
+ "internal",
+ "parent",
+ "sibling",
+ "index",
+ "object",
+ "type"
+ ]
+ }
+ ]
+ }
+}
diff --git a/server/.prettierrc b/server/.prettierrc
new file mode 100644
index 0000000..52f22af
--- /dev/null
+++ b/server/.prettierrc
@@ -0,0 +1,9 @@
+{
+ "semi": true,
+ "jsxSingleQuote": false,
+ "bracketSpacing": true,
+ "trailingComma": "none",
+ "printWidth": 90,
+ "tabWidth": 2,
+ "arrowParens": "always"
+}
\ No newline at end of file
diff --git a/server/controllers/query-param.types.ts b/server/controllers/query-param.types.ts
new file mode 100644
index 0000000..585b595
--- /dev/null
+++ b/server/controllers/query-param.types.ts
@@ -0,0 +1,5 @@
+export type RangeQueryParamType = [number, number];
+export type SortQueryParamType = [string, string] | Array<[string, string]>;
+export type FilterQueryParamType = {
+ [key: string]: unknown
+}
\ No newline at end of file
diff --git a/server/controllers/role/role.controller.ts b/server/controllers/role/role.controller.ts
index 8c4c7b0..a95b509 100644
--- a/server/controllers/role/role.controller.ts
+++ b/server/controllers/role/role.controller.ts
@@ -1,20 +1,23 @@
-import { NextFunction, Request, Response } from "express";
import Role from "../../models/role.model";
import { ApiErrorHandler } from "../../error/api-error.handler";
-import { IRoleDto } from "./role.dto";
-import { Order } from "sequelize";
-
-type RangeQueryParamType = [number, number];
-type SortQueryParamType = [string, string] | Array<[string, string]>;
-type FilterQueryParamType = {
- [key: string]: unknown
-}
+import type { Order } from "sequelize";
+import type { IRoleDto } from "./role.dto";
+import type { NextFunction, Request, Response } from "express";
+import type {
+ FilterQueryParamType,
+ RangeQueryParamType,
+ SortQueryParamType
+} from "../query-param.types";
class RoleController {
getAll = async (req: Request, res: Response, next: NextFunction) => {
try {
- const range: RangeQueryParamType = req.query.range ? JSON.parse(req.query.range.toString()) : [0, 10];
- const sort: SortQueryParamType = req.query.sort ? JSON.parse(req.query.sort.toString()) : ["id", "ASC"];
+ const range: RangeQueryParamType = req.query.range
+ ? JSON.parse(req.query.range.toString())
+ : [0, 10];
+ const sort: SortQueryParamType = req.query.sort
+ ? JSON.parse(req.query.sort.toString())
+ : ["id", "ASC"];
const roles = await Role.findAndCountAll({
offset: range[0],
@@ -26,19 +29,28 @@ class RoleController {
} catch (error) {
next(ApiErrorHandler.internal((error as Error).message));
}
- }
+ };
- // getMany = async (req, res, next) => {
- // try {
- // const filter = JSON.parse(req.query.filter);
- // const users = await User.findAll({ attributes: { exclude: ["slug"] }, where: { id: filter.ids } });
- // return res.json({ data: users });
- // } catch (error) {
- // next(ApiErrorHandler.internal(error.message));
- // }
- // }
+ getMany = async (req: Request, res: Response<{ data: Role[] }>, next: NextFunction) => {
+ try {
+ const filter: FilterQueryParamType = req.query.filter
+ ? JSON.parse(req.query.filter.toString())
+ : { ids: [] };
- create = async (req: Request<{}, {}, IRoleDto>, res: Response, next: NextFunction) => {
+ const roles = await Role.findAll({
+ where: { id: filter.ids as number[] }
+ });
+ return res.json({ data: roles });
+ } catch (error) {
+ next(ApiErrorHandler.internal((error as Error).message));
+ }
+ };
+
+ create = async (
+ req: Request