File tree Expand file tree Collapse file tree 3 files changed +12
-11
lines changed Expand file tree Collapse file tree 3 files changed +12
-11
lines changed Original file line number Diff line number Diff line change
1
+ import { ComponentType , ElementType } from 'react' ;
2
+
1
3
import { Button , Flex , Icon , useDisclosure } from "@chakra-ui/react"
2
4
import { FaPlus } from "react-icons/fa"
3
5
4
- import AddUser from "../Admin/AddUser"
5
- import AddItem from "../Items/AddItem"
6
-
7
6
interface NavbarProps {
8
7
type : string
8
+ addModalAs : ComponentType | ElementType
9
9
}
10
10
11
- const Navbar = ( { type } : NavbarProps ) => {
12
- const addUserModal = useDisclosure ( )
13
- const addItemModal = useDisclosure ( )
11
+ const Navbar = ( { type, addModalAs } : NavbarProps ) => {
12
+ const addModal = useDisclosure ( )
14
13
14
+ const AddModal = addModalAs
15
15
return (
16
16
< >
17
17
< Flex py = { 8 } gap = { 4 } >
@@ -26,12 +26,11 @@ const Navbar = ({ type }: NavbarProps) => {
26
26
variant = "primary"
27
27
gap = { 1 }
28
28
fontSize = { { base : "sm" , md : "inherit" } }
29
- onClick = { type === "User" ? addUserModal . onOpen : addItemModal . onOpen }
29
+ onClick = { addModal . onOpen }
30
30
>
31
31
< Icon as = { FaPlus } /> Add { type }
32
32
</ Button >
33
- < AddUser isOpen = { addUserModal . isOpen } onClose = { addUserModal . onClose } />
34
- < AddItem isOpen = { addItemModal . isOpen } onClose = { addItemModal . onClose } />
33
+ < AddModal isOpen = { addModal . isOpen } onClose = { addModal . onClose } />
35
34
</ Flex >
36
35
</ >
37
36
)
Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ import { Suspense } from "react"
20
20
import { type UserPublic , UsersService } from "../../client"
21
21
import ActionsMenu from "../../components/Common/ActionsMenu"
22
22
import Navbar from "../../components/Common/Navbar"
23
+ import AddUser from "../../components/Admin/AddUser"
23
24
24
25
export const Route = createFileRoute ( "/_layout/admin" ) ( {
25
26
component : Admin ,
@@ -93,7 +94,7 @@ function Admin() {
93
94
< Heading size = "lg" textAlign = { { base : "center" , md : "left" } } pt = { 12 } >
94
95
User Management
95
96
</ Heading >
96
- < Navbar type = { "User" } />
97
+ < Navbar type = { "User" } addModalAs = { AddUser } />
97
98
< TableContainer >
98
99
< Table fontSize = "md" size = { { base : "sm" , md : "md" } } >
99
100
< Thead >
Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ import { useEffect } from "react"
20
20
import { ItemsService } from "../../client"
21
21
import ActionsMenu from "../../components/Common/ActionsMenu"
22
22
import Navbar from "../../components/Common/Navbar"
23
+ import AddItem from "../../components/Items/AddItem"
23
24
24
25
const itemsSearchSchema = z . object ( {
25
26
page : z . number ( ) . catch ( 1 ) ,
@@ -135,7 +136,7 @@ function Items() {
135
136
Items Management
136
137
</ Heading >
137
138
138
- < Navbar type = { "Item" } />
139
+ < Navbar type = { "Item" } addModalAs = { AddItem } />
139
140
< ItemsTable />
140
141
</ Container >
141
142
)
You can’t perform that action at this time.
0 commit comments