Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
salimkanoun committed Sep 1, 2024
1 parent 77c5c64 commit 8aafcad
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 24 deletions.
9 changes: 2 additions & 7 deletions src/admin/users/UsersRoot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,7 @@ const UsersRoot = () => {
roundedBottomRight={false}
>
<Routes>
<Route path="/users" element={<Users isCreating={false} setIsCreating={function (value: boolean): void {
throw new Error("Function not implemented.");
} } />} />
<Route path="/users" element={<Users />} />
<Route path="/roles" element={<Roles />} />
<Route path="/oauth2" element={<Oauth2 />} />
</Routes>
Expand All @@ -75,10 +73,7 @@ const UsersRoot = () => {
</Button>
)}
{isCreatingUser && (
<CreateUserForm
title={"Create User"}
onClose={() => setIsCreatingUser(false)}
/>
<CreateUserForm />
)}
</>
)}
Expand Down
9 changes: 3 additions & 6 deletions src/admin/users/user/CreateUserForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,10 @@ import { getErrorMessage } from '../../../utils/error';
import InputPassword from '../../../ui/InputPassword';

type UserFormProps = {
title: string;
className?: string;
onClose: () => void;
};

const CreateUserForm = ({ title, className, onClose }: UserFormProps) => {
const CreateUserForm = ({ className }: UserFormProps) => {
const { toastSuccess, toastError } = useCustomToast();
const [firstName, setFirstName] = useState('');
const [lastName, setLastName] = useState('');
Expand Down Expand Up @@ -81,8 +79,7 @@ const CreateUserForm = ({ title, className, onClose }: UserFormProps) => {
return (
<FormCard
className={`${className} bg-light-gray`}
title={title}
onClose={onClose}
title={"Create user"}
onSubmit={handleSubmit}
>
<div className="grid grid-cols-1 col-span-3 gap-3 lg:grid-cols-3 lg:gap-11">
Expand Down Expand Up @@ -145,7 +142,7 @@ const CreateUserForm = ({ title, className, onClose }: UserFormProps) => {
options={rolesOptions ?? []}
placeholder="Select a Rôle"
onChange={(option) => setSelectedRole({ value: option.value, label: option.value })}

Check failure on line 144 in src/admin/users/user/CreateUserForm.tsx

View workflow job for this annotation

GitHub Actions / Build and publish

'option' is possibly 'null'.

Check failure on line 144 in src/admin/users/user/CreateUserForm.tsx

View workflow job for this annotation

GitHub Actions / Build and publish

'option' is possibly 'null'.
value={selectedRole}
value={selectedRole?.value ?? null}
/>
</label>
</div>
Expand Down
11 changes: 3 additions & 8 deletions src/admin/users/user/Users.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,9 @@ import EditUserForm from "./EditUserForm";

type UsersProps = {
className?: string;
isCreating: boolean;
setIsCreating: (value: boolean) => void;
};

const Users = ({ className, isCreating, setIsCreating }: UsersProps) => {
const Users = ({ className = "" }: UsersProps) => {
const { toastSuccess, toastError } = useCustomToast();
const { confirm } = useConfirm();
const [userToEdit, setUserToEdit] = useState<User | null>(null);
Expand All @@ -39,7 +37,6 @@ const Users = ({ className, isCreating, setIsCreating }: UsersProps) => {

const editUser = (user: User) => {
setUserToEdit(user);
setIsCreating(false);
};

const deleteUserHandler = async (user: User) => {
Expand Down Expand Up @@ -68,13 +65,11 @@ const Users = ({ className, isCreating, setIsCreating }: UsersProps) => {
/>
)}
<div>
{isCreating ? (

<CreateUserForm
title={"Create User"}
className="bg-gray-200"
onClose={() => setIsCreating(false)}
/>
) : null}

{userToEdit ? (
<EditUserForm
title={"Edit User"}
Expand Down
2 changes: 0 additions & 2 deletions src/ui/Badge.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import React from 'react';

type Size = "sm" | "md" | "lg" | "xl";

type BadgeProps = {
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"include": [
"src",
"types.d.ts",
"stories",
//"stories",
"vite-env.d.ts",
],
"references": [
Expand Down

0 comments on commit 8aafcad

Please sign in to comment.