1+ import { Edit , MoreVertical , Search , Trash } from 'lucide-react'
12import { useState } from 'react'
23import {
34 Button ,
45 DropdownMenu ,
56 DropdownMenuContent ,
67 DropdownMenuItem ,
78 DropdownMenuTrigger ,
8- IconEdit ,
9- IconMoreVertical ,
10- IconSearch ,
11- IconTrash ,
129 Input ,
1310} from 'ui'
1411
@@ -45,12 +42,13 @@ const EnumeratedTypes = () => {
4542 projectRef : project ?. ref ,
4643 connectionString : project ?. connectionString ,
4744 } )
48- const enumeratedTypes =
45+ const enumeratedTypes = ( data ?? [ ] ) . filter ( ( type ) => type . enums . length > 0 )
46+ const filteredEnumeratedTypes =
4947 search . length > 0
50- ? ( data ?? [ ] ) . filter (
48+ ? enumeratedTypes . filter (
5149 ( x ) => x . schema === selectedSchema && x . name . toLowerCase ( ) . includes ( search . toLowerCase ( ) )
5250 )
53- : ( data ?? [ ] ) . filter ( ( x ) => x . schema === selectedSchema )
51+ : enumeratedTypes . filter ( ( x ) => x . schema === selectedSchema )
5452
5553 const protectedSchemas = ( schemas ?? [ ] ) . filter ( ( schema ) =>
5654 EXCLUDED_SCHEMAS . includes ( schema ?. name ?? '' )
@@ -75,7 +73,7 @@ const EnumeratedTypes = () => {
7573 className = "w-64"
7674 onChange = { ( e ) => setSearch ( e . target . value ) }
7775 placeholder = "Search for a type"
78- icon = { < IconSearch size = { 14 } /> }
76+ icon = { < Search size = { 14 } /> }
7977 />
8078 </ div >
8179 { ! isLocked && (
@@ -103,7 +101,7 @@ const EnumeratedTypes = () => {
103101 ] }
104102 body = {
105103 < >
106- { enumeratedTypes . length === 0 && search . length === 0 && (
104+ { filteredEnumeratedTypes . length === 0 && search . length === 0 && (
107105 < Table . tr >
108106 < Table . td colSpan = { 4 } >
109107 < p className = "text-sm text-foreground" > No enumerated types created yet</ p >
@@ -113,7 +111,7 @@ const EnumeratedTypes = () => {
113111 </ Table . td >
114112 </ Table . tr >
115113 ) }
116- { enumeratedTypes . length === 0 && search . length > 0 && (
114+ { filteredEnumeratedTypes . length === 0 && search . length > 0 && (
117115 < Table . tr >
118116 < Table . td colSpan = { 4 } >
119117 < p className = "text-sm text-foreground" > No results found</ p >
@@ -123,8 +121,8 @@ const EnumeratedTypes = () => {
123121 </ Table . td >
124122 </ Table . tr >
125123 ) }
126- { enumeratedTypes . length > 0 &&
127- enumeratedTypes . map ( ( type ) => (
124+ { filteredEnumeratedTypes . length > 0 &&
125+ filteredEnumeratedTypes . map ( ( type ) => (
128126 < Table . tr key = { type . id } >
129127 < Table . td className = "w-20" >
130128 < p className = "w-20 truncate" > { type . schema } </ p >
@@ -136,23 +134,21 @@ const EnumeratedTypes = () => {
136134 < div className = "flex justify-end items-center space-x-2" >
137135 < DropdownMenu >
138136 < DropdownMenuTrigger asChild >
139- < Button type = "default" className = "px-1" >
140- < IconMoreVertical />
141- </ Button >
137+ < Button type = "default" className = "px-1" icon = { < MoreVertical /> } />
142138 </ DropdownMenuTrigger >
143139 < DropdownMenuContent side = "bottom" align = "end" className = "w-32" >
144140 < DropdownMenuItem
145141 className = "space-x-2"
146142 onClick = { ( ) => setSelectedTypeToEdit ( type ) }
147143 >
148- < IconEdit size = "tiny" />
144+ < Edit size = { 14 } />
149145 < p > Update type</ p >
150146 </ DropdownMenuItem >
151147 < DropdownMenuItem
152148 className = "space-x-2"
153149 onClick = { ( ) => setSelectedTypeToDelete ( type ) }
154150 >
155- < IconTrash stroke = "red" size = "tiny" />
151+ < Trash size = { 14 } />
156152 < p > Delete type</ p >
157153 </ DropdownMenuItem >
158154 </ DropdownMenuContent >
0 commit comments