File tree Expand file tree Collapse file tree 3 files changed +11
-12
lines changed Expand file tree Collapse file tree 3 files changed +11
-12
lines changed Original file line number Diff line number Diff line change 1
1
import { Button , Flex , Icon , useDisclosure } from "@chakra-ui/react"
2
+ import type { ComponentType , ElementType } from "react"
2
3
import { FaPlus } from "react-icons/fa"
3
4
4
- import AddUser from "../Admin/AddUser"
5
- import AddItem from "../Items/AddItem"
6
-
7
5
interface NavbarProps {
8
6
type : string
7
+ addModalAs : ComponentType | ElementType
9
8
}
10
9
11
- const Navbar = ( { type } : NavbarProps ) => {
12
- const addUserModal = useDisclosure ( )
13
- const addItemModal = useDisclosure ( )
14
-
10
+ const Navbar = ( { type, addModalAs } : NavbarProps ) => {
11
+ const addModal = useDisclosure ( )
12
+ const AddModal = addModalAs
15
13
return (
16
14
< >
17
15
< Flex py = { 8 } gap = { 4 } >
@@ -26,12 +24,11 @@ const Navbar = ({ type }: NavbarProps) => {
26
24
variant = "primary"
27
25
gap = { 1 }
28
26
fontSize = { { base : "sm" , md : "inherit" } }
29
- onClick = { type === "User" ? addUserModal . onOpen : addItemModal . onOpen }
27
+ onClick = { addModal . onOpen }
30
28
>
31
29
< Icon as = { FaPlus } /> Add { type }
32
30
</ Button >
33
- < AddUser isOpen = { addUserModal . isOpen } onClose = { addUserModal . onClose } />
34
- < AddItem isOpen = { addItemModal . isOpen } onClose = { addItemModal . onClose } />
31
+ < AddModal isOpen = { addModal . isOpen } onClose = { addModal . onClose } />
35
32
</ Flex >
36
33
</ >
37
34
)
Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ import {
16
16
import { useQueryClient , useSuspenseQuery } from "@tanstack/react-query"
17
17
import { createFileRoute } from "@tanstack/react-router"
18
18
19
+ import AddUser from "@/components/Admin/AddUser"
19
20
import { Suspense } from "react"
20
21
import { type UserPublic , UsersService } from "../../client"
21
22
import ActionsMenu from "../../components/Common/ActionsMenu"
@@ -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 @@ -16,6 +16,7 @@ import { useQuery, useQueryClient } from "@tanstack/react-query"
16
16
import { createFileRoute , useNavigate } from "@tanstack/react-router"
17
17
import { z } from "zod"
18
18
19
+ import AddItem from "@/components/Items/AddItem"
19
20
import { useEffect } from "react"
20
21
import { ItemsService } from "../../client"
21
22
import ActionsMenu from "../../components/Common/ActionsMenu"
@@ -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