@@ -10,7 +10,7 @@ import {
1010} from "@/components/ui/dialog"
1111import { Button } from "@/components/ui/button" ;
1212import { Separator } from "@/components/ui/separator" ;
13- import type { QuoteFormData } from "@/model/quote.model" ;
13+ import type { QuoteFormData , SortOption } from "@/model/quote.model" ;
1414import {
1515 Select ,
1616 SelectItem ,
@@ -19,21 +19,35 @@ import {
1919 SelectTrigger ,
2020} from "@/components/ui/select"
2121import { useState } from "react" ;
22- import { useTheme , type ThemeMode } from '@/hook/use-dark-or-light-theme.hook'
22+ import { themeModes , useTheme , type ThemeMode } from '@/hook/use-dark-or-light-theme.hook'
2323import { ArrowLeftIcon , CircleArrowDown , CircleCheckBig , Copy , Images , LoaderCircle , Save , Share , Settings } from "lucide-react" ;
2424import { colorThemes , useColorTheme , type ColorTheme } from "@/hook/use-color-theme.hook" ;
25+ import { showInfo , useShowCardInfo , type ShowInfo } from "@/hook/use-show-card-info.hook" ;
26+ import { capitalize } from "@/helper/capitalize" ;
2527
28+ interface SortOptions { key : SortOption , label : string }
2629
30+ const sortOptions : SortOptions [ ] = [
31+ {
32+ key : "created_at" ,
33+ label : "Created at" ,
34+ } ,
35+ {
36+ key : "updated_at" ,
37+ label : "Updated at" ,
38+ } ,
39+ ]
2740interface Props {
2841
2942}
3043
3144export function SettingComponent ( props : Props ) {
32-
3345 const { theme, setTheme } = useTheme ( )
34- const { colorTheme, setColorTheme } = useColorTheme ( )
3546 const [ open , setOpen ] = useState ( false )
47+ const { colorTheme, setColorTheme } = useColorTheme ( )
48+ const { info, setInfo } = useShowCardInfo ( )
3649
50+ const [ sortBy , setSortBy ] = useState < SortOptions [ "key" ] > ( "created_at" )
3751
3852 return (
3953 < Dialog open = { open } onOpenChange = { setOpen } >
@@ -55,42 +69,109 @@ export function SettingComponent(props: Props) {
5569 </ DialogDescription >
5670 </ DialogHeader >
5771 < Separator className = "bg-border" />
58- < div className = "flex flex-col gap-4" >
59- < div className = "flex justify-between gap-4" >
72+ < div className = "flex flex-col gap-2 text-sm" >
73+ < p className = "text-muted-foreground text-xs" > App Style</ p >
74+ < div className = "flex justify-between items-center " >
6075 Appearance
6176 < Select value = { theme } onValueChange = { ( value ) => setTheme ( value as ThemeMode ) } >
6277 < SelectTrigger className = "" >
63- < SelectValue placeholder = "Theme " />
78+ < SelectValue placeholder = "Appearance " />
6479 </ SelectTrigger >
6580 < SelectContent >
66- < SelectItem value = "light" > Light</ SelectItem >
67- < SelectItem value = "dark" > Dark</ SelectItem >
68- < SelectItem value = "system" > System</ SelectItem >
81+ {
82+ themeModes . map ( ( pri ) => {
83+ const yo = capitalize ( pri )
84+ return (
85+ < SelectItem key = { pri } value = { pri } className = "text-capitalize capitalize" >
86+ { yo }
87+ </ SelectItem >
88+ )
89+ } )
90+ }
6991 </ SelectContent >
7092 </ Select >
7193 </ div >
72- < Separator className = "bg-border" />
73- < div className = "flex justify-between gap-4" >
94+ < div className = "flex justify-between items-center " >
7495 Color Theme
75- < Select value = { colorTheme } onValueChange = { ( value ) => setColorTheme ( value as ColorTheme ) } >
96+ < Select
97+ value = { colorTheme }
98+ onValueChange = { ( value ) => setColorTheme ( value as ColorTheme ) } >
7699 < SelectTrigger className = "" >
77- < SelectValue placeholder = "Color Theme" />
100+ < SelectValue placeholder = "Color Theme" className = "text-capitalize capitalize" />
78101 </ SelectTrigger >
79- < SelectContent >
102+ < SelectContent className = "" >
80103 {
81104 colorThemes . map ( ( pri ) => {
105+ const yoyo = pri . replace ( "theme-" , "" )
106+ const yo = capitalize ( yoyo )
107+ console . log ( { yo, yoyo } )
108+ return (
109+ < SelectItem key = { pri } value = { pri } className = "" >
110+ { yo }
111+ </ SelectItem >
112+ )
113+ } )
114+ }
115+ </ SelectContent >
116+ </ Select >
117+ </ div >
118+ < div className = "flex justify-between items-center " >
119+ Sort by
120+ < Select value = { sortBy } onValueChange = { ( value ) => setSortBy ( value as SortOption ) } >
121+ < SelectTrigger className = "" >
122+ < SelectValue placeholder = "Sort By" />
123+ </ SelectTrigger >
124+ < SelectContent >
125+ {
126+ sortOptions . map ( ( pri ) => {
127+ let yo = capitalize ( pri . key )
82128 return (
83- < SelectItem key = { pri } value = { pri } className = "text-capitalize capitalize" > { pri } </ SelectItem >
129+ < SelectItem key = { pri . key } value = { pri . key } className = "" >
130+ { yo . replaceAll ( '_' , " " ) }
131+ </ SelectItem >
84132 )
85133 } )
86134 }
87135 </ SelectContent >
88136 </ Select >
89137 </ div >
138+ </ div >
90139
140+ < Separator className = "bg-border" />
91141
142+ < div className = "flex flex-col gap-2" >
143+ < p className = "text-muted-foreground text-xs" > Card Style</ p >
144+ < div className = "flex justify-between items-center " >
145+ Show Info
146+ < Select value = { info } onValueChange = { ( value ) => setInfo ( value as ShowInfo ) } >
147+ < SelectTrigger className = "" >
148+ < SelectValue placeholder = "Show Info" />
149+ </ SelectTrigger >
150+ < SelectContent >
151+ {
152+ showInfo . map ( ( pri ) => {
153+ let yo = pri . charAt ( 0 ) . toUpperCase ( ) + pri . slice ( 1 )
154+ return (
155+ < SelectItem key = { pri } value = { pri } className = " " >
156+ { yo . replaceAll ( '_' , " " ) }
157+ </ SelectItem >
158+ )
159+ } )
160+ }
161+ </ SelectContent >
162+ </ Select >
163+ </ div >
164+ </ div >
92165
166+ < Separator className = "bg-border" />
167+
168+ < div className = "flex flex-col gap-2" >
169+ < p className = "text-muted-foreground text-xs" > Other</ p >
170+ < div className = "flex justify-between text-center " >
171+ Made with 💙 by Pritam
172+ </ div >
93173 </ div >
174+
94175 </ DialogContent >
95176 </ Dialog >
96177 ) ;
0 commit comments