File tree Expand file tree Collapse file tree 1 file changed +38
-3
lines changed
apps/desktop/src/components/onboarding Expand file tree Collapse file tree 1 file changed +38
-3
lines changed Original file line number Diff line number Diff line change 11import { platform } from "@tauri-apps/plugin-os" ;
2+ import { CalendarIcon } from "lucide-react" ;
23
4+ import { Button } from "@hypr/ui/components/ui/button" ;
5+
6+ import { usePermission } from "../../hooks/usePermissions" ;
37import { useAppleCalendarSelection } from "../main/body/calendar/apple/calendar-selection" ;
48import { SyncProvider } from "../main/body/calendar/apple/context" ;
59import { ApplePermissions } from "../main/body/calendar/apple/permission" ;
@@ -18,18 +22,49 @@ function AppleCalendarList() {
1822 ) ;
1923}
2024
25+ function RequestCalendarAccess ( {
26+ onRequest,
27+ isPending,
28+ } : {
29+ onRequest : ( ) => void ;
30+ isPending : boolean ;
31+ } ) {
32+ return (
33+ < div className = "flex flex-col items-center justify-center py-6 px-4 border rounded-lg" >
34+ < CalendarIcon className = "size-6 text-neutral-300 mb-2" />
35+ < Button
36+ variant = "outline"
37+ size = "sm"
38+ onClick = { onRequest }
39+ disabled = { isPending }
40+ >
41+ Request Access to Calendar
42+ </ Button >
43+ </ div >
44+ ) ;
45+ }
46+
2147export function CalendarSection ( { onContinue } : { onContinue : ( ) => void } ) {
2248 const isMacos = platform ( ) === "macos" ;
49+ const calendar = usePermission ( "calendar" ) ;
50+ const isAuthorized = calendar . status === "authorized" ;
2351
2452 return (
2553 < div className = "flex flex-col gap-4" >
2654 { isMacos && (
2755 < div className = "flex flex-col gap-4" >
2856 < ApplePermissions />
2957
30- < SyncProvider >
31- < AppleCalendarList />
32- </ SyncProvider >
58+ { isAuthorized ? (
59+ < SyncProvider >
60+ < AppleCalendarList />
61+ </ SyncProvider >
62+ ) : (
63+ < RequestCalendarAccess
64+ onRequest = { calendar . request }
65+ isPending = { calendar . isPending }
66+ />
67+ ) }
3368 </ div >
3469 ) }
3570
You can’t perform that action at this time.
0 commit comments