Skip to content

Commit cfdc5b4

Browse files
feat: replace 'No calendars found' with 'Request Access to Calendar' button in onboarding (#4171)
Co-authored-by: Sungbin Jo <goranmoomin@daum.net> Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
1 parent e023b83 commit cfdc5b4

File tree

1 file changed

+38
-3
lines changed

1 file changed

+38
-3
lines changed

apps/desktop/src/components/onboarding/calendar.tsx

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
import { 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";
37
import { useAppleCalendarSelection } from "../main/body/calendar/apple/calendar-selection";
48
import { SyncProvider } from "../main/body/calendar/apple/context";
59
import { 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+
2147
export 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

0 commit comments

Comments
 (0)