@@ -7,10 +7,10 @@ import { Progress } from "@/components/ui/progress"
77import { cn } from "@/lib/utils"
88import { motion , AnimatePresence } from "framer-motion"
99import { toast } from "sonner"
10+ import { getCarStatus } from "@/api/status" ;
1011
1112export function CarInfo ( ) {
1213 const [ batteryLevel , setBatteryLevel ] = useState ( 80 )
13- const [ temperature , setTemperature ] = useState ( 72 )
1414 const [ isLocked , setIsLocked ] = useState ( true )
1515 const [ isAcOn , setIsAcOn ] = useState ( false )
1616 const [ isCharging , setIsCharging ] = useState ( false )
@@ -29,6 +29,18 @@ export function CarInfo() {
2929 return ( ) => clearInterval ( interval )
3030 } , [ isCharging , batteryLevel ] )
3131
32+ useEffect ( ( ) => {
33+ getCarStatus ( ) . then ( data => {
34+ if ( data ) {
35+ setIsConnected ( true )
36+ } else {
37+ setIsConnected ( false )
38+ }
39+ } ) . catch ( ( ) => {
40+ setIsConnected ( false )
41+ } )
42+ } , [ ] )
43+
3244 const getBatteryColor = ( ) => {
3345 if ( batteryLevel > 50 ) return "bg-green-500"
3446 if ( batteryLevel > 20 ) return "bg-yellow-500"
@@ -128,12 +140,12 @@ export function CarInfo() {
128140 < div className = "flex items-center gap-2" >
129141 < motion . span
130142 className = "font-medium"
131- key = { temperature }
143+ key = { 72 }
132144 initial = { { opacity : 0 , y : - 10 } }
133145 animate = { { opacity : 1 , y : 0 } }
134146 transition = { { duration : 0.3 } }
135147 >
136- { temperature } °F
148+ { 72 } °F
137149 </ motion . span >
138150 < Button
139151 variant = "outline"
0 commit comments