@@ -10,15 +10,24 @@ import {
1010import { Input } from '@renderer/components/ui/input'
1111import { Button } from '@renderer/components/ui/button'
1212import { Card , CardContent , CardHeader , CardTitle } from '@renderer/components/ui/card'
13- import { Save , RotateCcw , Building2 , Phone , Building , Wand2 } from 'lucide-react'
13+ import { Save , RotateCcw , Building2 , Phone , Building , Wand2 , RefreshCw } from 'lucide-react'
1414import { useForm } from 'react-hook-form'
1515import { z } from 'zod'
1616import { zodResolver } from '@hookform/resolvers/zod'
17- import { useMutation , useQueryClient } from '@tanstack/react-query'
17+ import { useMutation , useQuery , useQueryClient } from '@tanstack/react-query'
1818import { useSettings } from '@renderer/contexts/SettingsContext'
1919import { queries } from '@renderer/lib/queries'
2020import { useEffect } from 'react'
2121import { toast } from '@renderer/components/ui/sonner'
22+ import {
23+ Select ,
24+ SelectContent ,
25+ SelectItem ,
26+ SelectTrigger ,
27+ SelectValue
28+ } from '@renderer/components/ui/select'
29+
30+ type UpdateChannel = 'stable' | 'beta' | 'alpha'
2231
2332const formSchema = z . object ( {
2433 hospital : z . string ( ) ,
@@ -40,6 +49,22 @@ export const GeneralSettings = () => {
4049 }
4150 } )
4251
52+ const { data : updateChannel = 'stable' } = useQuery ( {
53+ queryKey : [ 'updateChannel' ] ,
54+ queryFn : ( ) => window . electronApi . getUpdateChannel ( )
55+ } )
56+
57+ const updateChannelMutation = useMutation ( {
58+ mutationFn : ( channel : UpdateChannel ) => window . electronApi . setUpdateChannel ( channel ) ,
59+ onSuccess : ( ) => {
60+ queryClient . invalidateQueries ( { queryKey : [ 'updateChannel' ] } )
61+ toast . success ( 'Update channel changed' )
62+ } ,
63+ onError : ( error : Error ) => {
64+ toast . error ( error . message )
65+ }
66+ } )
67+
4368 useEffect ( ( ) => {
4469 if ( settings ) {
4570 form . reset ( {
@@ -193,10 +218,78 @@ export const GeneralSettings = () => {
193218 </ CardContent >
194219 </ Card >
195220
221+ { /* Update Channel Card */ }
222+ < Card
223+ className = "bg-gradient-to-br from-card to-card/80 animate-fade-in-up overflow-hidden"
224+ style = { { animationDelay : '75ms' } }
225+ >
226+ < CardHeader className = "pb-4 pt-5 relative" >
227+ < div className = "absolute top-0 right-0 w-32 h-32 bg-green-500/5 rounded-full -translate-y-1/2 translate-x-1/2 blur-2xl" />
228+ < div className = "flex items-center gap-3 relative" >
229+ < div className = "h-10 w-10 rounded-xl bg-gradient-to-br from-green-500/20 to-green-600/20 flex items-center justify-center border border-green-500/20" >
230+ < RefreshCw className = "h-5 w-5 text-green-500" />
231+ </ div >
232+ < div >
233+ < CardTitle className = "text-base font-semibold" > Update Channel</ CardTitle >
234+ < p className = "text-xs text-muted-foreground mt-0.5" >
235+ Choose which updates you receive
236+ </ p >
237+ </ div >
238+ </ div >
239+ </ CardHeader >
240+
241+ < CardContent className = "pt-0" >
242+ < div className = "space-y-4" >
243+ < div >
244+ < label className = "text-sm font-medium mb-2 block" > Release Channel</ label >
245+ < Select
246+ value = { updateChannel }
247+ onValueChange = { ( value : UpdateChannel ) => updateChannelMutation . mutate ( value ) }
248+ disabled = { updateChannelMutation . isPending }
249+ >
250+ < SelectTrigger className = "w-full md:w-64 h-11" >
251+ < SelectValue placeholder = "Select channel" />
252+ </ SelectTrigger >
253+ < SelectContent >
254+ < SelectItem value = "stable" >
255+ < div className = "flex flex-col items-start" >
256+ < span className = "font-medium" > Stable</ span >
257+ < span className = "text-xs text-muted-foreground" >
258+ Recommended for most users
259+ </ span >
260+ </ div >
261+ </ SelectItem >
262+ < SelectItem value = "beta" >
263+ < div className = "flex flex-col items-start" >
264+ < span className = "font-medium" > Beta</ span >
265+ < span className = "text-xs text-muted-foreground" >
266+ Preview upcoming features
267+ </ span >
268+ </ div >
269+ </ SelectItem >
270+ < SelectItem value = "alpha" >
271+ < div className = "flex flex-col items-start" >
272+ < span className = "font-medium" > Alpha</ span >
273+ < span className = "text-xs text-muted-foreground" >
274+ Bleeding edge, may be unstable
275+ </ span >
276+ </ div >
277+ </ SelectItem >
278+ </ SelectContent >
279+ </ Select >
280+ < p className = "text-xs text-muted-foreground mt-2" >
281+ Stable releases are thoroughly tested. Beta and alpha channels receive updates
282+ earlier but may contain bugs.
283+ </ p >
284+ </ div >
285+ </ div >
286+ </ CardContent >
287+ </ Card >
288+
196289 { /* Setup Wizard Card */ }
197290 < Card
198291 className = "bg-gradient-to-br from-amber-500/5 to-amber-600/5 border-amber-500/20 animate-fade-in-up"
199- style = { { animationDelay : '75ms ' } }
292+ style = { { animationDelay : '150ms ' } }
200293 >
201294 < CardHeader className = "pb-3 pt-4" >
202295 < div className = "flex items-center gap-2.5" >
0 commit comments