@@ -5,11 +5,10 @@ import PostgresFilters from "@/components/postgres/postgres-filters";
55import PostgresSort from "@/components/postgres/postgres-sort" ;
66import { Skeleton } from "@/components/ui/skeleton" ;
77import { Table , TableBody , TableHead , TableHeader , TableRow } from "@/components/ui/table" ;
8- import { Tooltip , TooltipContent , TooltipTrigger } from "@/components/ui/tooltip" ;
98import { DatabaseConnection } from "@/types/database" ;
109import { TableRecord } from "@/types/postgres" ;
11- import { CodeIcon , KeyIcon , TableIcon } from "lucide-react" ;
12- import { useState } from "react" ;
10+ import { CalendarIcon , CheckIcon , CodeIcon , HashIcon , KeyIcon , SigmaIcon , TableIcon , TextIcon } from "lucide-react" ;
11+ import { ReactElement , useState } from "react" ;
1312import DeletePostgresRow from "./delete-postgres-row" ;
1413import EditPostgresRow from "./edit-postgres-row" ;
1514import PostgresTableRow from "./postgres-table-row" ;
@@ -102,15 +101,29 @@ const TableDataDisplay = ({
102101 }
103102 } ;
104103
105- const PrimaryKeyIcon = ( { isPrimaryKey } : { isPrimaryKey : boolean | undefined } ) => {
106- return isPrimaryKey ? (
107- < Tooltip >
108- < TooltipTrigger >
109- < KeyIcon className = "text-primary size-3 rotate-45" />
110- </ TooltipTrigger >
111- < TooltipContent > Primary Key</ TooltipContent >
112- </ Tooltip >
113- ) : null ;
104+ const getColumnIcon = ( column : ColumnData ) => {
105+ const icons : ReactElement [ ] = [ ] ;
106+ if ( column . is_primary_key ) {
107+ icons . push ( < KeyIcon className = "text-primary size-3 rotate-45" /> ) ;
108+ }
109+ if ( / ^ ( t e x t | c h a r a c t e r | v a r c h a r | c h a r | c i t e x t ) / . test ( column . data_type ) ) {
110+ icons . push ( < TextIcon className = "text-primary size-3" /> ) ;
111+ }
112+ if ( / ^ ( i n t e g e r | b i g i n t | s m a l l i n t | n u m e r i c | d e c i m a l | f l o a t | d o u b l e ) / . test ( column . data_type ) ) {
113+ icons . push ( < SigmaIcon className = "text-primary size-3" /> ) ;
114+ }
115+ if ( / ^ ( b o o l e a n | b o o l ) / . test ( column . data_type ) ) {
116+ icons . push ( < CheckIcon className = "text-primary size-3" /> ) ;
117+ }
118+ if ( / ^ ( d a t e | t i m e | t i m e s t a m p | i n t e r v a l ) / . test ( column . data_type ) ) {
119+ icons . push ( < CalendarIcon className = "text-primary size-3" /> ) ;
120+ } else if ( / ^ ( j s o n | j s o n b ) / . test ( column . data_type ) ) {
121+ icons . push ( < CodeIcon className = "text-primary size-3" /> ) ;
122+ } else if ( / ^ ( u u i d | u u i d - o s s p ) / . test ( column . data_type ) ) {
123+ icons . push ( < HashIcon className = "text-primary size-3" /> ) ;
124+ }
125+
126+ return icons ;
114127 } ;
115128
116129 return (
@@ -149,7 +162,7 @@ const TableDataDisplay = ({
149162 { columns . map ( ( column , index ) => (
150163 < TableHead key = { index } className = "h-10" >
151164 < div className = "flex items-center gap-1 align-middle" >
152- < PrimaryKeyIcon isPrimaryKey = { column . is_primary_key } />
165+ { getColumnIcon ( column ) }
153166 { column . column_name }
154167 < span className = "font-mono text-xs text-gray-500" > ({ column . data_type } )</ span >
155168 </ div >
0 commit comments