Browse Source

add more types

Signed-off-by: shanghaikid <jiangruiyi@gmail.com>
shanghaikid 1 year ago
parent
commit
aaff654480
2 changed files with 10 additions and 8 deletions
  1. 8 6
      client/src/pages/user/CreateUser.tsx
  2. 2 2
      client/src/pages/user/Types.ts

+ 8 - 6
client/src/pages/user/CreateUser.tsx

@@ -14,6 +14,7 @@ import { ITextfieldConfig } from '@/components/customInput/Types';
 import { useFormValidation } from '@/hooks/Form';
 import { useFormValidation } from '@/hooks/Form';
 import { formatForm } from '@/utils/Form';
 import { formatForm } from '@/utils/Form';
 import { CreateUserProps, CreateUserParams } from './Types';
 import { CreateUserProps, CreateUserParams } from './Types';
+import { Option as RoleOption } from '@/components/customSelector/Types';
 
 
 const useStyles = makeStyles((theme: Theme) => ({
 const useStyles = makeStyles((theme: Theme) => ({
   input: {
   input: {
@@ -126,19 +127,20 @@ const CreateUser: FC<CreateUserProps> = ({
         </Typography>
         </Typography>
 
 
         <FormGroup row>
         <FormGroup row>
-          {roles.map((r: any, index: number) => (
+          {roles.map((r: RoleOption, index: number) => (
             <FormControlLabel
             <FormControlLabel
               control={
               control={
                 <Checkbox
                 <Checkbox
-                  onChange={(e: React.ChangeEvent<HTMLInputElement>, checked: boolean) => {
+                  onChange={(
+                    e: React.ChangeEvent<HTMLInputElement>,
+                    checked: boolean
+                  ) => {
                     let newRoles = [...form.roles];
                     let newRoles = [...form.roles];
 
 
                     if (!checked) {
                     if (!checked) {
-                      newRoles = newRoles.filter(
-                        (n: string | number) => n === r.vlaue
-                      );
+                      newRoles = newRoles.filter((n: string) => n === r.value);
                     } else {
                     } else {
-                      newRoles.push(r.value);
+                      newRoles.push(String(r.value));
                     }
                     }
 
 
                     setForm(v => ({ ...v, roles: [...newRoles] }));
                     setForm(v => ({ ...v, roles: [...newRoles] }));

+ 2 - 2
client/src/pages/user/Types.ts

@@ -1,4 +1,4 @@
-import { Option } from '@/components/customSelector/Types';
+import { Option as RoleOption } from '@/components/customSelector/Types';
 
 
 export interface UserData {
 export interface UserData {
   name: string;
   name: string;
@@ -26,7 +26,7 @@ export interface UpdateUserRoleProps {
 export interface CreateUserProps {
 export interface CreateUserProps {
   handleCreate: (data: CreateUserParams) => void;
   handleCreate: (data: CreateUserParams) => void;
   handleClose: () => void;
   handleClose: () => void;
-  roles: Option[];
+  roles: RoleOption[];
 }
 }
 
 
 export interface UpdateUserProps {
 export interface UpdateUserProps {